Backslashed escape sequences
Rob Landley
rob at landley.net
Mon Sep 22 10:20:52 UTC 2008
On Sunday 21 September 2008 11:32:15 Marc W. Abel wrote:
> Thanks to everyone participating in this discussion. I really like all
> this attention to detail.
>
> Program \e == \033 ?
> ---------------------------------------
> bash echo yes
> bash printf yes
> coreutils echo no
> coreutils printf no
>
> I'm not sure (vda) how you'll adopt "their" behavior, as "they" differ.
> It comes down to scope; I don't think BusyBox has ever adopted bash as a
> standard to follow,
Yes, it has.
The thing about bash is that it's been the official shell of Linux since
before it was called "Linux". If you read "Just for Fun", it goes over the
history of the Linux kernel.
Linus Torvalds started out his Unix use by using a Sinclair with a modem to
connect to the university's microvax, and hang out on usenet. When he got a
386, he installed Minix on it, but the micro-kernel nature of Minix couldn't
keep up with a 2400 bps modem without dropping characters, so he wrote his
own term program in 386 assembly, which booted from a floppy and talked
directly to the hardware. He made it multi-threaded (with a trivial process
scheduler) as a teaching exercise, using one thread to read from keyboard and
write to modem, and a second thread reading from modem and writing to the
screen.
The problem was he wanted to upload and download files, which meant he had to
teach it to write to the filesystem, meaning it needed to understand the
minix filesystem layout. He did that, but he had to reboot into minix in
order to delete files to make space, or create directories, rename files,
etc. So to avoid so many reboots, he added a system call interface to his
terminal program and taught it to handle all the system calls bash needed.
It was, specifically, bash. Bash was the first unix program he taught his
term program to run, and the need to run Bash is what caused his term program
to evolve into a unix kernel. Bash has been the standard shell of every
LInux system ever since, up until Ubuntu swapped in the Defective Annoying
SHell which (among other things) broke the Linux kernel build.
Now these were mostly old versions of bash. I stopped paying attention to
anything that went in after 2.04b. But things like curly bracket file
listing syntax, or echo needing -e? You encounter them all over the place in
Linux.
(And note that if you use dash, echo doesn't support options at all.
No "echo -e" or "echo -n". Yeah, that breaks things.)
I have several scripts that use \e as the start of ansi escape sequences, by
the way. (Octal's a bit 1970's for my tastes...)
Rob
More information about the busybox
mailing list