Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在linux中传入read bash变量并在git commit中作为消息发送?_Linux_Bash_Git - Fatal编程技术网

如何在linux中传入read bash变量并在git commit中作为消息发送?

如何在linux中传入read bash变量并在git commit中作为消息发送?,linux,bash,git,Linux,Bash,Git,我希望自动执行git提交功能,并能够在bash中读取如下消息: echo -n "Enter message and press [ENTER]: " read mess cd /my/dir git add * git commit -m "$(mess)" 但是,它在bash中告诉我,在第6行:未找到mess:command。有什么地方我做错了吗?在脚本中,$(mess)表示执行命令的子shellmess;这不是真正的命令 将括号替换为括号 echo-n“输入消息并按[Enter]:”

我希望自动执行git提交功能,并能够在bash中读取如下消息:

echo -n "Enter message and press [ENTER]: " 
read mess

cd /my/dir
git add *
git commit -m "$(mess)"
但是,它在bash中告诉我,在
第6行:未找到mess:command。
有什么地方我做错了吗?

在脚本中,
$(mess)
表示执行命令的子shell
mess
;这不是真正的命令

将括号替换为括号

echo-n“输入消息并按[Enter]:”
阅读混乱
cd/my/dir
git添加*
git commit-m“${mess}”
更新

根据,在命令替换下,它声明如下:

命令替换允许命令的输出替换命令名。有两种形式: $(命令) 或 `命令` Bash通过执行命令并用命令的标准输出替换命令替换来执行扩展,并删除所有后续换行符

在脚本中,
$(mess)
表示执行命令
mess
的子shell;这不是真正的命令

将括号替换为括号

echo-n“输入消息并按[Enter]:”
阅读混乱
cd/my/dir
git添加*
git commit-m“${mess}”
更新

根据,在命令替换下,它声明如下:

命令替换允许命令的输出替换命令名。有两种形式: $(命令) 或 `命令` Bash通过执行命令并用命令的标准输出替换命令替换来执行扩展,并删除所有后续换行符


谢谢,这可能是基本的,但什么是子shell?我已经在答案中添加了定义。谢谢,我支持你的答案,非常感谢!谢谢,这可能是基本的,但什么是子shell?我已经在答案中添加了定义。谢谢,我支持你的答案,非常感谢!