2

Is it possible to echo out a string in tcsh such that it is fully escaped, as tcsh would understand? In the same way as printf %q works in bash:

% # Create a variable containing a tab character
% MYMONKEY=$'my\tmonkey'
% printf %q "$MYMONKEY"
$'my\tmonkey'

Which can then be used to re-input the variable into bash. Anyone know of anything similar in tcsh?

1 Answers1

0

Workaround idea:

in tcsh

set MYMONKEY="my\tmonkey"

Note you do not add a "\n" at the end so the output will reflect this decision:

 printf "%s" $MYMONKEY
 my\tmonkey_My_Login_Name_@myhost>

 to fix it you can use 

 printf "%s\n" $MYMONKEY
 my\tmonkey
 _My_Login_Name_@myhost>

or

 printf $MYMONKEY
 my      monkey_My_Login_Name_@myhost>_

 echo $MYMONKEY
 my      monkey
 _My_Login_Name_@myhost>_
Hastur
  • 19,483
  • 9
  • 55
  • 99