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!

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux