Odd bash construction...
Context: I'm trying to spruce up the jboss_init_redhat.sh file that comes with a jboss installation, so that it provides the same [ OK ] / [ FAILED ] flags that most of the other /etc/init.d/ scripts have. The file is jboss's auto start/stop for RH.
(I don't have to, but it's a good way to stretch my scripting knowledge...) I'm using /etc/init.d/sshd as my model, and I've encountered this echo line: Code:
echo -n $"Starting $prog: " What in the world is that dollar sign supposed to be doing? Turning the whole string into a variable?! Thanks! dafydd |
This is done for localization. It allows the string to be translated to a different language depending on your locale.
For example, after a bit of setup, I can print the output of this code in another language: Code:
#!/bin/bash Code:
$ LANG=en_US.utf8 Code:
$ LANG=fr_FR.utf8 |
Slick! Thanks for the hint.
|
Notice that there's also a single-quoted version, $'string', that has a different, more generally useful purpose. Any ansi-c style backslash escapes will be expanded into their literal equivalents, and the result will be a hard-quoted string. It's generally equivalent to the "-e" option in echo.
Code:
$ echo $'foo\tbar\nbaz\tbum' |
All times are GMT -5. The time now is 07:42 PM. |