Re: annoying BASH does not interpret quotation marks right?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Filippos Klironomos wrote:
> Somehow this seems counterintuitive but the suggestion not to escape the
> quotemarks worked. You would expect that escaping the quotemarks you
> create the exact command you would manually type yourself for BASH, but
> apparently it does not work like that...
> 
> 
For me, escaping the quote marks would be counterintuitive. You are
quoting the variable to tell the shell that it is to be treated as
one "word", even if it has spaces in it. When you escape the quotes,
you are telling the shell to ignore the quote, and pass it directly
to the program it is running. The end result is that if the variable
 has a space in it, it gets split at the space.

Another way to look at it is that you enter the commands in a script
the same way you would on the command line. If you wanted to, you
could manually enter each line of the script at the command prompt,
and it would work.

There is an exception to entering the commands exactly as you would
on the command line. If you are creating scripts that will be run by
cron, or in a non-login shell, you may have to set up the shell
environment yourself in the script. The biggest thing that gets
people writing scripts for cron is that the path used by the script
is a lot more limited then the one when you are logged in, so the
script may not find some commands when run by cron, but it works
fine when run from the command line.

Mikkel
-- 

  Do not meddle in the affairs of dragons,
for thou art crunchy and taste good with Ketchup!


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux