I'm trying to figure out how to create a bash with multiple arguments, and one argument has multiple flags. I need to do this to open xterm, navigate to bash script, and execute it with arguments.
This is my code:
#!/bin/bash
if [ "$Running_In_New_Xterm" != t ] ; then
Running_In_New_Xterm=exec xterm -hold -e "cd $3 && $1 $2"
Running_In_New_Xterm=t
fi
$2 is a command to run flags on $1 -a blah -o blahblah
I'm trying to determine the proper way to execute #2. I read I have to add ' ' when having an argument with multiple spaces, but I am trying that on the input side, and it isn't working. I get " unexpected EOF while looking for matching `' ' " which suggests my problem has something to do with the fact that $2 isn't being executed correctly. I'm at the point I think it has something to do with the bash itsel.
xterm
, you also assignRunning_In_New_Xterm
in the (environment ofxterm
) the value ofexec
. Is that a typo?Running_In_New_Xterm=exec
.-e "cd $3 && $1 $2"
does not work? What is the exact resulting command line you want executed (as you would type it into a shell)?