[Sig] Re: [Lvlug] Bash: how format a number to a string?

Ryan, Paul PRyan@propoint.com
Mon, 7 May 2001 09:18:32 -0500


This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C0D700.9888FC20
Content-Type: text/plain;
	charset="iso-8859-1"

Well, at least you tried it.  I wasn't really trying to get you to switch,
just offering a solution.  The Korn and C shells aren't for everyone.  It
takes at least a year of UNIX experience before you can begin to appreciate
them.  By then, most Linux users have become hooked on bash and won't/can't
switch.  "bash" allows you to be productive right from the start and does
have a wide range of features.  

Choosing a shell is like choosing a car.  Sometimes one fits your
requirements perfectly, you buy it and you're happy with it.  This is rare.
Most often, you choose based on a compromise of your requirements (and
budget), you buy it and you're happy with it.  For me, the Korn shell is a
"best fit" situation and I'm happy with it.

As for which shell to invoke for your script, you again have a decision.  If
you want portability, use Bourne since it's available everywhere.  If you
want string processing power, use ksh.  If you want arrays beyond the 1023
element limit, look toward the csh family.  Remembering that scripts are
usually written for system startup or maintenance tasks or to automate
personal drudge tasks, and not to do power computing, I find Korn the best
fit.  Time isn't a factor and ease of maintenance is.

Perhaps "shells" could be a presentation topic?  I'll be happy to demo the
features of ksh.  Anyone in the club want to take on the 

*(a|ba|c|z|?)sh 

shell? 

Paul

-----Original Message-----
From: Randy Kramer
To: Ryan, Paul
Cc: lvlug@thelinuxlink.net; sig@thelinuxlink.net
Sent: 5/7/01 8:44 AM
Subject: Re: [Sig] Re: [Lvlug] Bash: how format a number to a string?

Paul,

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!
Randy Kramer


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
> commands:
>   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
> started.
> 
> Let me know how you make out.
> 
> Paul
> 
> 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.

------_=_NextPart_001_01C0D700.9888FC20
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">



RE: [Sig] Re: [Lvlug] Bash: how format a number to a =
string?



Well, at least you tried it.  I wasn't really = trying to get you to switch, just offering a solution.  The Korn = and C shells aren't for everyone.  It takes at least a year of = UNIX experience before you can begin to appreciate them.  By then, = most Linux users have become hooked on bash and won't/can't = switch.  "bash" allows you to be productive right from = the start and does have a wide range of features. 

Choosing a shell is like choosing a car.  = Sometimes one fits your requirements perfectly, you buy it and you're = happy with it.  This is rare.  Most often, you choose based = on a compromise of your requirements (and budget), you buy it and = you're happy with it.  For me, the Korn shell is a "best = fit" situation and I'm happy with it.

As for which shell to invoke for your script, you = again have a decision.  If you want portability, use Bourne since = it's available everywhere.  If you want string processing power, = use ksh.  If you want arrays beyond the 1023 element limit, look = toward the csh family.  Remembering that scripts are usually = written for system startup or maintenance tasks or to automate personal = drudge tasks, and not to do power computing, I find Korn the best = fit.  Time isn't a factor and ease of maintenance is.

Perhaps "shells" could be a presentation = topic?  I'll be happy to demo the features of ksh.  Anyone in = the club want to take on the

*(a|ba|c|z|?)sh

shell?

Paul

-----Original Message-----
From: Randy Kramer
To: Ryan, Paul
Cc: lvlug@thelinuxlink.net; = sig@thelinuxlink.net
Sent: 5/7/01 8:44 AM
Subject: Re: [Sig] Re: [Lvlug] Bash: how format a = number to a string?

Paul,

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!
Randy Kramer


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
> commands:
>   set -o emacs
>   export PS1=3D'$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
> started.
>
> Let me know how you make out.
>
> Paul
>
> 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.

------_=_NextPart_001_01C0D700.9888FC20--