Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
12-16-2013, 12:31 AM
|
#1
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Rep: 
|
What would break with a very early version of bash?
I've been trying out sh and ash as my sign in shell and liked very much the speed and lightness.
I was also pleased that nearly all my scripts were compatible - I changed them to #!/bin/sh or ash. I even changed the sh symbolic link in /bin from bash to ash and that worked fine until shutdown, when the system crashed
Not so compatible startup and shutdown scripts
But the fact is that in interactive mode both ash and sh are uncomfortable.
Basically, I would like to have ash but with command line editing, a useful prompt and it to recognise "cd bin" to mean the relative directory bin in the current directory and not "/bin".
In anycase - I was wondering, what would break if I went back to a very early form of bash?
|
|
|
12-16-2013, 12:34 AM
|
#2
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Maybe you should try dash instead.
|
|
|
12-16-2013, 12:40 AM
|
#3
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
I did try Dash but soon stopped as it seems to have the same restrictions as ash.
It is only little things which are annoying - such as not being able to set up the prompt to remind me in which directory I am in. Dash is the same as ash with regard to that.
That's why am I thinking about an early version of bash - it should be small and fast but would have, I hope, those few, little enhancements which I want.
|
|
|
12-16-2013, 01:05 AM
|
#4
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
Originally Posted by harryhaller
It is only little things which are annoying - such as not being able to set up the prompt to remind me in which directory I am in.
|
|
|
|
12-16-2013, 01:12 AM
|
#5
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
That becomes a constant - it doesn't change when you change directories.
|
|
|
12-16-2013, 01:29 AM
|
#6
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
bash-2.05b would come closest to working, but I think there are still rc scripts which will bomb with that -rc.inet1 uses arrays which are not supported by bash2. There may be other rc scripts which are using newer bash features.
|
|
|
12-16-2013, 01:53 AM
|
#7
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
Yes, rc.inet1 and rc.S seem to be the only ones there using arrays.
That looks good, because with my setup I think I could use older versions of those scripts (maybe modify them). I only have eth0 so I it looks good.
|
|
|
12-16-2013, 02:05 AM
|
#8
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
Gnashley - would I get any problems with src2pkg? I use that quite often.
Otherwise, if inet1 and S are the only foreseeable problems, it's worth a try - I can download bash from slackware release 9.1 and recompile it. Thanks for the help.
|
|
|
12-16-2013, 02:07 AM
|
#9
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
Originally Posted by harryhaller
That becomes a constant - it doesn't change when you change directories.
|
Yeah, you're right. (I made the same stupid mistake when I was *bleeping* around with ksh almost 20 years ago(!).) The only solutions that I've seen would have you run a program to do the substitutions when the prompt string is printed out.
The other comments pretty much pointed out that what you want in an interactive shell may not be what you want in a scripting shell. (IOW, use bash/ksh for the stuff that *you* type in but use ash/dash for a script.)
|
|
1 members found this post helpful.
|
12-16-2013, 03:37 AM
|
#10
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
@harryhaller, yes, unfortunately src2pkg uses bash3-isms in at least one place. It's possible that others have crept in over time. I'd be willing to fix that though. I did consider revising it to run using dash at least, but decided not to as I use bashisms throughout. The bash3-ism I know of is the use of indirect variable substitution like: '${!var}'. 'twould be easy enough to fix with a harmless eval -that would be the first use of eval in src2pkg, I think.
I've struggled with the question of using dash or ash as /bin/sh, but there are just too many scripts out there using bashisms but with the /bin/sh shebang. Still, I wanted to use dash as the shell for init scripts to have a faster boot. So, what I did was invent a shell called /bin/initsh (linked to static dash) and have all init scripts using that. This allows me to keep /bin/sh pointing to bash and still have a faster shell for other things. If your scripts work with ash or dash, then I'd change their shebangs to /bin/ash and have /bin/ash as a link to /bin/dash. This would still allow you to keep /bin/sh as bash.
|
|
1 members found this post helpful.
|
12-16-2013, 10:10 AM
|
#11
|
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
|
You may have noticed that sh is actually BASH emulating sh?
Code:
ls -al /bin/sh
lrwxrwxrwx 1 root root 4 Nov 24 13:31 /bin/sh -> bash*
KornShell on Slackware is actual KornShell, not an emulator. I've been exclusively using KornShell for (literally) decades with no inclination whatsoever to switch to anything else; BASH is a pain in the ASH.
Command line editing? Hit the up arrow key or Esc-K and edit away with vi/ex editing sequences. Easy alias?
Code:
cat .kshrc
alias lc='/usr/bin/clear; /bin/ls ${LS_OPTIONS} -aCF'
alias ll='/bin/ls ${LS_OPTIONS} -al'
alias cls='clear'
alias hi='history -${LINES}'
alias rs='eval `resize`'
Set up a KornShell environment?
Code:
cat .profile
# set up default columns and lines
COLUMNS=80
LINES=40
export COLUMNS LINES
# set up a good-size history
HISTSIZE=1000
export HISTSIZE
# set up the ksh environment
ENV=${HOME}/.kshrc
export ENV
# change the PATH a little
export PATH=.:${HOME}/bin:${PATH}
# make COLUMNS and LINES the screen size
eval `resize`
Make it all work on log-in?
Code:
cat /etc/profile.d/ksh.sh
#!/bin/sh
#ident "$Id$"
#
# Name: $Source$
# Version: $Revision$
# Modified: $Date$
# Purpose: set local environment variables for Korn Shell
# Author: T. N. Ronayne
# Date: 1 Oct 2009
# $Log$
# Set the HOST environment variable
export HOST="`uname -n`"
# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
# VISUAL=emacs # ugh
# VISUAL=gmacs # double ugh
VISUAL=vi # ah, elegence
fi
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
# Do these anyway in case sombody uses a different shell
if [ "$SHELL" = "/bin/pdksh" ]; then
PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
PS1='${HOST}-${USER}-${PWD}: '
elif [ "$SHELL" = "/bin/zsh" ]; then
PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
PS1='$ '
else
PS1='\u@\h:\w\$ '
fi
PS2='> '
export PS1 PS2
What could be simpler, one might ask.
Hope this helps some.
|
|
|
12-16-2013, 10:27 AM
|
#12
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Since the OP is looking for something that is more lightweight than the current version of bash, I don't think that ksh will cut the mustard:
Code:
$ ls -lart /bin/ksh
-rwxr-xr-x 1 root root 1498632 Jun 9 2013 /bin/ksh*
$ ls -lart /bin/bash
-rwxr-xr-x 1 root root 973672 Aug 15 14:17 /bin/bash*
$ ldd /bin/ksh
linux-vdso.so.1 (0x00007fff68dff000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f8319604000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007f8319400000)
libm.so.6 => /lib64/libm.so.6 (0x00007f83190fe000)
libc.so.6 => /lib64/libc.so.6 (0x00007f8318d35000)
/lib64/ld-linux-x86-64.so.2 (0x00007f8319842000)
$ ldd /bin/bash
linux-vdso.so.1 (0x00007fff3f780000)
libtermcap.so.2 => /lib64/libtermcap.so.2 (0x00007fe9703b9000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fe9701b4000)
libc.so.6 => /lib64/libc.so.6 (0x00007fe96fdeb000)
/lib64/ld-linux-x86-64.so.2 (0x00007fe9705f6000)
Maybe ksh initialization code is faster than bash's, but I wouldn't expect any speedups from switching to ksh. YMMV.
Last edited by Richard Cranium; 12-16-2013 at 10:28 AM.
Reason: added "the current version of", which is more precise.
|
|
|
12-16-2013, 10:29 AM
|
#13
|
LQ Guru
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,414
|
if it can be useful, this is not bad for automated checking
http://sourceforge.net/projects/checkbaskisms/
|
|
1 members found this post helpful.
|
12-16-2013, 11:18 AM
|
#14
|
Member
Registered: May 2004
Distribution: BSD
Posts: 269
Rep: 
|
mksh installed from pkgsrc:
Code:
-rwxr-xr-x 1 root root 264496 Oct 4 13:52 /usr/pkg/bin/mksh*
There is also a SlackBuild.
|
|
1 members found this post helpful.
|
12-16-2013, 11:24 AM
|
#15
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
Of course I know that /bin/sh is a link to /bin/bash. You know that bash's 'emulation' of 'sh' still includes some bash extensions which are not POSIX. Exactly why there are lots of scripts out that where the author probably thinks they were compatible with (real) 'sh', when in fact they are not.
|
|
|
All times are GMT -5. The time now is 09:11 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|