Skip to main content
edited body
Source Link
Hauke Laging
  • 94.6k
  • 21
  • 132
  • 185

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"-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.

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.

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.

Source Link
Jacob
  • 11
  • 1

Bash with multiple spaces in single argument

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.