sh - How can I split a shell command over multiple lines when using an IF statement? -


how can split command on multiple lines in shell, when command part of if statement?

while works:

if ! fab --fabfile=.deploy/fabfile.py --forward-agent --disable-known-hosts deploy:$target; rc=1                                                                        fi 

this not working:

# not work: if ! fab --fabfile=.deploy/fabfile.py \   --forward-agent \   --disable-known-hosts deploy:$target;      rc=1 fi 

instead of whole command executing, get:

./script.sh: line 73: --forward-agent: command not found 

more importantly, missing understanding of bash me understand , similar issues in future?

the line-continuation fail if have whitespace (spaces or tab characters) after backslash , before newline. no such whitespace, example works fine me:

$ cat test.sh if ! fab --fabfile=.deploy/fabfile.py \    --forward-agent \    --disable-known-hosts deploy:$target;      echo failed else      echo succeeded fi  $ alias fab=true; . ./test.sh succeeded $ alias fab=false; . ./test.sh failed 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -