I am developing a bash script in Windows 7 using a bash emulated terminal, exactly I use bash terminal in MobaXterm 9.1. The reason is that I have a Windows 7 laptop but my script would eventually run on a Jenkins Linux Server.Spaces and/or ( in path are preventing my script from running successfully.My script is:#!/bin/basheclexe0=C:\Program Files (x86)\HPCCSystems\6.0.4\clienttools\bin\ecl.exeeclexe1=/drives/c/Program Files (x86)/HPCCSystems/6.0.4/clienttools/bin/ecl.execlear#1echo Testing if ecl.exe is available...if [ -f $eclexe0 ]; then  echo FOUND. >&2else  echo NOT FOUND. >&2  exit 1fiecho Executing ecl.exeecho 1eval $eclexe0echo 2When I run it the output isAs you can see script is not happy with path C:\Program Files (x86). If I move files to another path (C:\oscar\eclfolder) it works. I tried the answers here but they don't work, probably because I am in a Windows 7...How can I make this script work?
Bash script not working due to path C:\Program Files (x86)... in Windows
bash;shell script;windows;quoting
Your script doesn't work because you are running eval on the pathname to the executable file.In any shell script, you can already use a variable to specify a command to run.If you don't quote your $variable reference, the contents of the variable will also be split into separate words according to whitespace.You have quoted your variable reference.  However, by running eval, you are parsing the result of the variable expansion a second time.  You don't need to.The following illustration may be instructive:$ lsfile.txt    file2.txt$ somevar=ls$ $somevarfile.txt    file2.txt$ ls -ltotal 0-rw-r--r--  1 Me  staff  0 Sep  2 16:06 file.txt-rw-r--r--  1 Me  staff  0 Sep  2 16:06 file2.txt$ somevar='ls -l'$ $somevartotal 0-rw-r--r--  1 Me  staff  0 Sep  2 16:06 file.txt-rw-r--r--  1 Me  staff  0 Sep  2 16:06 file2.txt$ $somevarbash: ls -l: command not found$ As you can see, when I attempt to run ls -l, quoted, the shell looks for a command with that exact namespaces included.In my example, that's not what I want.However, in your example, that is what you want.Instead of using eval $eclexe0, just use $eclexe0.The Bigger PictureFree advice: If you plan to run your script on a Linux box, test it on a Linux box.  MobaXterm is not a Linux box.Install Vagrant and VirtualBox (which are both free) and create a virtual machine you can do your tests in.Further reading:Why does my shell script choke on whitespace or other special characters?The Wooledge Bash Guide