Control characters in the shell

Karl Heuer karl at IMA.IMA.ISC.COM
Thu Mar 22 06:51:46 AEST 1990


From: karl at IMA.IMA.ISC.COM (Karl Heuer)

This came up in comp.org.usrgroup, but I think this is a better place.

Observation: The shell, considered as a programming language, has a string
datatype but does not have adequate facilities for embedding nonprinting
characters in a string constant.  As a result, several commands (date, echo,
paste, prs, stty, tr) have evolved (largely incompatible) notations for
translating escape sequences into such nonprinting characters.

Opinion: A much cleaner solution would be to have a simple shell syntax which
causes the nonprinting characters to be embedded into the argument string, so
that it would be transparent to the program.

Proposal: Reserve $\ (dollar-backslash) as a new entity that begins a C-like
escape, so we would have $\a $\b $\t $\n $\v $\f $\r, octal escapes like
$\177, and hex escapes like $\x7F.

Alternative proposal (from a suggestion by Eric Gisin, eric at mks.com): make a
new string quoting mechanism, $"...", which is just like "..." except that, in
addition to the four current backslash escapes \$ \` \" \\ that are permitted
inside double quotes, all the C-like escapes \a etc. would be recognized.

I'm told that the POSIX shell does not address this perceived deficiency.  I
hope it's not too late for this to be corrected.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint

Volume-Number: Volume 19, Number 20



More information about the Comp.std.unix mailing list