[Sig] Re: [Lvlug] Bash: how format a number to a string?
Mon, 07 May 2001 09:44:15 -0400
Thanks very much for the information.
I have the script working by using the #!/bin/ksh as the "shebang"
line. (For a little while I was worried that I was doing something ugly
like building up a bunch of calls to ksh and bash on the "call stack",
but I think that was a result of some experimentation I did, effectively
alternately invoking ksh and bash from the command line. I exited many
times and cleared the problem up, and I don't think it will happen when
I invoke the script.) (If anybody needs or wants to look at the
semifinished version of the script, let me know -- it may stay
semifinished for a long time.)
I briefly tried ksh as a replacement for bash following your
instructions. I don't think I'm ready to make the change, maybe someday
if I learn emacs or vi, or I find the lack of typeset or similar
features from the command line to be a major problem. (As you showed
me, I can invoke a script in ksh and overcome that lack.)
Just for the sake of exchanging information, the reasons I plan to stick
with bash for the time being include:
1. I don't recognize any missing features in bash aside from typeset --
bash has a command line history (which can be edited in .bash_history
(IIRC)) and can be scrolled and edited using the up and down arrows.
Bash also has a configurable command line prompt which shows me the
PWD. It is set to show just the last directory, which I've grown used
to -- I assume I could change it to show the entire PWD if I wanted to.
(And no, nobody has to tell me about assume.)
2. I'm not familiar / comfortable with the editing keys you list below
(I guess they are emacs?). In bash I can use the up and down arrows to
scroll through history, the backspace key for a "destructive" backspace,
delete to delete the character at the cursor, the left and right arrows
to navigate across the line. I've also learned about keys like <ctrl>e
(end of line), <ctrl>a (beginning of line), <alt>b (back one word), and
<alt>f (forward one word), although I'd really prefer that those keys be
End, Home, <ctrl><left_arrow>, and <ctrl><right_arrow> respectively.
(And, sooner or later, I'll learn how to reassign those keys, whether it
be via bash or via xmodkeys (or both).)
3. I guess the most frustrating thing in my brief foray into trying ksh
was that I could not find a "nondestructive backspace" key. (I didn't
look very much beyond your list and some likely guesses (IMO) -- I'm
probably a bad guesser.)
Thanks again for your help!
Ryan, Paul wrote:
> I normally use the Korn shell (or PDKSH when I'm on a Linux box) since
> that is what I train students in. Since the mid-80's it's been the
> most POSIX compliant of the shell family and has a large following.
> As for subdirectories, I place system scripts in /usr/local/sbin or
> /usr/local/bin, depending on whose gonna run'em. I also have a
> scripts directory under $HOME, and an entry to it in my path. There
> are those who would advise against that for security reasons. You'll
> have to decide.
> The bash shell is a sub-set/super-set (I guess that's a disjoint set!)
> of the Korn and Bourne shells, developed by Brian Fox and Chet Ramey
> of the Free Software Foundation to include the best of all worlds and
> leave out the excess. However, as you saw with the typeset statement,
> it isn't fully compliant. FSF was working on a complete freely
> distributable UNIX-compatible operating system (GNU) and bash (which
> stands for Bourne-Again SHell) was to be the default shell. Linux
> came along and and it became the darling of the Linux set.
> bash is fully Bourne compliant, but only partially incorporates the
> Korn and c shell features like aliases, functions, tilde notation, job
> control, etc.,. It does, however, have one or two features that the
> other shells lack. I must admit that when I first installed Linux I
> tried and liked bash because it was there and easy to start with.
> Now, I only use the Korn shell because of its powerful command line
> editting capabilities based on vi, it's use of the print command
> (instead of echo) and other features.
> To try it, type ksh at the command line, then issue these two
> set -o emacs
> export PS1='$PWD: '
> Everything above is case sensitive (of course, it's UNIX!), there are
> spaces around the -o and NO SPACES around the equal sign. After that,
> things should look pretty bash-like to you. The prompt will track
> your current working directory and the arrow keys will walk you around
> command history and allow you to edit a line. Normal emacs commands
> are understood as well. A short set includes:
> ^P - previous command
> ^N - Next command
> ^A - Beginning of line
> ^E - End of line
> ^D - Delete character under cursor
> I'm a vi freak and don't play with emacs much, but those few should
> get you started. If you know vi, than issue the `set -o vi` command
> and use vi commands to edit your history buffer. ESC-k should get you
> Let me know how you make out.
> P.S The Korn shell compliments of David Korn (AT&T) and the Bourne
> shell from Steven Bourne. The C-shell was written by Bill Joy (UC
> Berkeley) whose name may ring a bell. The first major shell was the
> Bourne shell and it still continues as a standard. Hence, most system
> scripts are written to use it since it is on every UNIX/Linux system.