Subject: Re: Single user mode: ed(1) or bust
To: None <>
From: Lasse =?ISO-8859-1?Q?Hiller=F8e?= Petersen <>
List: netbsd-users
Date: 05/16/2007 19:58:45
matthew sporleder wrote:

>$ echo $SHELL

>if [ "$x" = "I am fine." ]

It seems both ksh and sh have [ as a builtin - makes me wonder: why is
there still a /bin/[ in NetBSD?

Andrew's suggestion to use pre/suffix variable substitution deserves to
be spelled out, as I am sure I am not alone in not knowing enough about
that great shell feature:

echo ${l%%pat*}subst${l##*pat}

can almost, but not quite, make up for ${l/pat/subst} in bash. You'll
have to use some additional logic similar to what matthew suggested:

case $l in (*pat*)echo ${l%%pat*}subst${l##*pat} ;; (*)echo $l;;esac

but of course it's still not as powerful as Bash. It has the advantage
of working even if you don't have Bash, however. :-)

Anyway, it's amazing how powerful the shell is, and how much you can do
with it even when your system is totally hosed and you can't start any
new processes.

This makes you wonder why some people prefer GUIs to a shell. Or, FSM
forbid, prefer csh.

OK, in all fairness, csh *does* have ${var:s/pat/sub/}

BTW, according to the csh manpage:
           s/l/r/  Substitute l for r

Is that correct English? I found one example of "substitute X for Y"
with Google, with the meaning of X replacing Y. "with" instead of
"for" would probably be better.