The file XXX is marked as an executable but could not be run by the operating system

文章目录

    fish shell 中执行我自己写一个 shell 脚本时,报错

    > lazy
    Failed to execute process '/home/zhongwei/bin/lazy'. Reason:
    exec: Exec format error
    The file '/home/zhongwei/bin/lazy' is marked as an executable but could not be run by the operating system.
    

    lazy 中的代码很简单,就是一行,为了我自己偷懒时使用

    > cat ~/bin/lazy
    git commit -a -m"update"
    

    我猜测是 fish shell 中必须指定 shell 名称。

    修改成

    > cat ~/bin/lazy
    #!/bin/bash
    
    set -e  # or use "set -o errexit" to quit on error.
    set -x  # or use "set -o xtrace" to print the statement before you execute it.
    
    git commit -a -m"update"
    

    就一切正常了。