我想運行存儲在bash中的變量的命令。
我的bash文件:
#!/bin/bash
# -----------------------------------------------
# --- COMMANDS ---
# --- Vanilla style ---
# -----------------------------------------------
GRUNT="node_modules/grunt-cli/bin/grunt"
LS="ls"
# -----------------------------------------------
# --- COMMANDS ---
# --- Using Docker ---
# -----------------------------------------------
GRUNT="docker exec compose_custom-node_1 node_modules/grunt-cli/bin/grunt"
LS="docker exec compose_custom-node_1 ls"
# ***********************************************
# *** Execution ***
# ***********************************************
# -----------------------------------------------
# Compile SCSS using Grunt
# -----------------------------------------------
echo "Building CSS from Sass files..."
echo "$(docker exec compose_custom-node_1 ls -l)"
echo "$($LS -l)"
$($GRUNT sass)
問題:
當我運行此bash的文件時,grunt sass
命令拋出一個錯誤:
mybash.sh: line 25: $'\E[4mRunning' : command not found
我的bash的整體回報:
[email protected]:/var/www/my_folder$ ./my_bash.sh
Building CSS from Sass files...
total 188
-rw-rw-r-- 1 node node 3627 May 2 19:00 Gruntfile.js
drwxr-xr-x 282 root root 12288 May 3 12:12 node_modules
drwxr-xr-x 4 node node 4096 May 2 18:39 sass
total 188
-rw-rw-r-- 1 node node 3627 May 2 19:00 Gruntfile.js
drwxr-xr-x 282 root root 12288 May 3 12:12 node_modules
drwxr-xr-x 4 node node 4096 May 2 18:39 sass
my_bash.sh: ligne 25: $'\E[4mRunning' : commande introuvable
調查:
命令echo "$(docker exec compose_custom-node_1 ls -l)"
和echo "$($LS -l)"
似乎工作,但不是$($GRUNT sass)
。
如果我在終端上運行docker exec compose_custom-node_1 node_modules/grunt-cli/bin/grunt
,我看到這樣的輸出:
Running "sass:app1" (sass) task
Running "sass:sticky-app2" (sass) task
Done, without errors.
問:
你對我有線索?我做錯了什麼?
如果在終端中運行docker exec compose_custom-node_1 node_modules/grunt-cli/bin/grunt sass會發生什麼情況?這似乎是您的問題命令正在運行 – arco444
@ arco444與運行'docker exec compose_custom-node_1 node_modules/grunt-cli/bin/grunt'相同 – darckcrystale
有關此類問題的常見問題,請參閱http://mywiki.wooledge。 org/BashFAQ/050 –