Results 1 to 10 of 16
Code:
echo 'Don\'t tell me this doesn\'t work'
Under sh or bash, can anyone tell me why this resorts to my second prompt?...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-19-2003 #1Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
sh and the single quote
Under sh or bash, can anyone tell me why this resorts to my second prompt?Code:echo 'Don\'t tell me this doesn\'t work'
The best things in life are free.
- 06-19-2003 #2Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
Within single quotes, _nothing_ except the ending quote is recognized, not even backslash. Therefore, to accomplish that, you must use this:
Code:echo 'Don'\'' tell me this doesn'\''t work'
- 06-19-2003 #3Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
Hmm. I guess I better e-mail the author of this book. One of her examples does exactly what I wrote before.
The best things in life are free.
- 06-19-2003 #4Linux Guru
- Join Date
- Oct 2001
- Location
- Täby, Sweden
- Posts
- 7,578
I'm absolutely not sure, but I have a faint memory that I actually have used that technique before, in an older version of bash, so maybe they have deleted that functionality after the book was released. I might very well remember it all wrong, though. Try mailing her; she might know the truth behind it.
- 06-20-2003 #5Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
I was doing this kind of thing in RedHat 7.3 and I don't recall this giving me a problem. Of course I was using bash instead of ash at the time (since I never installed sh) but don't recall it giving me a problem. Now in Debian, it doens't work in ash 0.3.8-7 or bash 2.05a-11. Eitherway, I e-mailed the author and hopefully she'll write back to resolve this problem.
I got another question regarding sh (not bash) and it's functions. I'm able to set a function but for some reason, it's not unsetting correctly.
That's how that goes but normal variables can be unset easily with the unset command. It's the functions that are a problem.Code:$ greet() { echo "Greet Baby!!"; } $ greet Greet Baby!! $ set | grep greet _='greet' $ unset greet $ greet Greet Baby!!
The best things in life are free.
- 06-20-2003 #6Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
Well, I just read the man page for ash and it clearly states that it's NOT possible to put a single quote within a single quote. Sorry for all this nuisance.
The best things in life are free.
- 06-20-2003 #7Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
BTW, what command can I use to know the current shell that I'm running?
The best things in life are free.
- 06-20-2003 #8Linux Engineer
- Join Date
- Jan 2003
- Location
- Lebanon, pa
- Posts
- 994
echo $SHELL
- 06-20-2003 #9Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
That won't work if I change shells to a different shell than the default assigned by /bin/login.
The best things in life are free.
- 06-20-2003 #10Linux Engineer
- Join Date
- Nov 2002
- Location
- Queens, NY
- Posts
- 1,319
The only thing that I've gotten close to is 'ps | grep $$'
The best things in life are free.


Reply With Quote
