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

发布时间: 2019-03-21 14:38:48 作者: 大象笔记

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"

就一切正常了。

我是一名山东烟台的开发者,联系作者