Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 May 2014 18:39:42 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Andre Goree <andre@drenet.net>
Cc:        FreeBSD Questions <freebsd-questions@freebsd.org>
Subject:   Re: csh and echo
Message-ID:  <20140529183942.7119a5e6.freebsd@edvax.de>
In-Reply-To: <6afd2e37bfc1736513878d896c5c8314@drenet.net>
References:  <6afd2e37bfc1736513878d896c5c8314@drenet.net>

next in thread | previous in thread | raw e-mail | index | archive | help
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'
	$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0



> Bash does not seem to have this same issue:
> 
> root@fbsdtest13:~ # echo "$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0"
> rVxldcGZ: Undefined variable.
> root@fbsdtest13:~ # bash
> [root@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'
	$1$rVxldcGZ$CisrIAX4SBYUkMJt9KjXl0

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




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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140529183942.7119a5e6.freebsd>