コンテキスト:バッシュエラー「コマンドが見つかりません」
私は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 –