... I would appreciate a way to keep this eval out sound not really as a question, but it is.
–
F. HauriDec 25 '12 at 7:05

Ah OK. For \n, try echo -e. It is still not very clear what exactly is being asked in other parts of the question. Why are you using echo at all? What's wrong with printf $"message key" $var1 $var2?
–
n.m.Dec 25 '12 at 7:21

@n.m. I complain that $"$msg" will work fine only if $msg don't contain a \n. If so, need to write ugly thing like eval... \$\""$msg"\"...
–
F. HauriDec 25 '12 at 7:34

1

I'd suggest trying the help-bash mailing list. This is a feature that's rarely used both because it's obscure, and because of security bugs. Even people that do a lot of scripting don't tend to use it.
–
ormaajDec 25 '12 at 9:19

Yes, thank, I've seen that too, but as you said: this is not really -the- answer ;-) But +1 as your way of storing and re-using$message is cleaner as what I've already tested. (Initial idea was using bash associative array for storing all messages, so I could imagine a nice way of doing that with your syntax.)
–
F. HauriDec 25 '12 at 14:05

1

...cleaner and more efficient... if all message have to be printed at least on time or more; Your way run translation when setting variable, when mine run translation when used... More or less, depending on what, when and how...
–
F. HauriDec 25 '12 at 14:20

You can probably mix $"..." and $'...' for the desired effect. msg=$'Written by %s.\n'; echo $"$msg"
–
tripleeeJan 1 '13 at 17:54

Yes sure, but if this let us keep evaland ugly form out, this add a fork and this is not as quick as invoking $"...". But thank for contrib!
–
F. HauriDec 25 '12 at 21:41

If you can produce profiling data that pinpoint this fork as the performance bottleneck in your system, you probably should not have written it in bash in the first place.
–
n.m.Dec 25 '12 at 21:51

difference exist (as tiny they are). The feature exist. So if they exist why did a need to use expensive fork? While each time cost have to be reduced, I think your comment is not constructive.
–
F. HauriDec 26 '12 at 10:29

2

More electrons are probably wasted on this thread than ever will be on all these forks...
–
n.m.Dec 26 '12 at 11:26

1

A shell script that doesn't invoke any external programs probably shouldn't be a shell script. Note the subshell doesn't really add any cost. It's a single fork+exec either way. @n.m. I'd use local variables, or better, use the parameters directly. It's also not a very good idea to expand a variable into the first argument of printf, especially in Bash, especially when it results from calling an external program. The -v option can result in executing arbitrary code. Also, shift can take an argument to indicate the number of shifts.
–
ormaajDec 29 '12 at 7:02