LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Yet Another Bash Quotes Within Quotes Issue (https://www.linuxquestions.org/questions/linux-software-2/yet-another-bash-quotes-within-quotes-issue-791073/)

catkin 02-25-2010 11:59 AM

Quote:

Originally Posted by tboyer (Post 3876458)
Never noticed that before - what's -bash?

It means the source command has been used since the shell was started (as is normal when using bash startup files such as /etc/profile and ~/.bashrc) More in this LQ post and later in the same thread (thanks jinkels :))

Schrambo 11-01-2012 01:05 AM

This can be a big problem and I often run into this issue. However I can usially get around it by surrounding the command with a backquote "`"

This guide (page) has a good little section explaining the differences and behavors of single and double quotes along with escape characters and the super handy backquote that I had just mentioned and backslash which we all love.

http://linuxreviews.org/beginner/Bas...O/en/x303.html

David the H. 11-03-2012 11:17 AM

The big problem is that variables are the shell's data structures. They are not designed for holding or executing commands. This includes, in particular, quote marks and other shell syntax characters.

I'm trying to put a command in a variable, but the complex cases always fail!
http://mywiki.wooledge.org/BashFAQ/050

The proper solution is to define a shell function for the command, and avoid the whole issue.

Code:

errmail() {
        echo "backup unmount failed"
        /bin/mailx -s "Error from ${0##*/} root"
        exit 1
}

/bin/umount /data_backup || errmail


Oh, and please use ***[code][/code]*** tags around your code and data, to preserve the original formatting and to improve readability. Do not use quote tags, bolding, colors, "start/end" lines, or other creative techniques.


All times are GMT -5. The time now is 01:57 PM.