csh and echo

Polytropon freebsd at edvax.de
Thu May 29 16:39:51 UTC 2014

On Thu, 29 May 2014 12:02:35 -0400, Andre Goree wrote:
> I'm writing a script within which I need to have encrypted passwords 
> passed to 'pw mod user'.  My issue is that csh does not seem to escape 
> the the "$" correctly and thus I receive an "Undefined variable" error 
> message.

The csh does exactly what it should to. Use '...' instead of "..."
to avoid evaluations within a string, for example:

	% echo '$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0'

> Bash does not seem to have this same issue:
> root at fbsdtest13:~ # echo "$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0"
> rVxldcGZ: Undefined variable.
> root at fbsdtest13:~ # bash
> [root at fbsdtest13 ~]# echo "$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0"

It's not an issue, it's intended. Strings enclosed in "..." are
allowed to contain variables, whereas strings enclosed in '...'
are being processed without expansion.

	$ echo '$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0'

I'm sure this is mentioned somewhere in "man bash", as well as
in "man csh" regarding the C Shell. :-)

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list