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, 11:38 AM
|
#16
|
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
|
Quote:
Originally Posted by Richard Cranium
Maybe ksh initialization code is faster than bash's, but I wouldn't expect any speedups from switching to ksh. YMMV.
|
Don't know about the speed-up part, but I do know about the reliability one: KornShell does not break anything, anywhere at any time. Start up, shut down, nothing breaks. It's fully compatible with Bourne Shell (guess where it came from, eh?). I do know that it's reliable as the day is long -- no glitches, no gotchas, it just works (and has, for me, since the 1980's on multiple platforms).
It's hard to judge speed on a modern platform with fast, multi-core processors, reasonably large RAM, fast disks and all that sort of thing. I know that KornShell was fast on early Motorola 68K's, fast on SPARCs, fast on Pentiums and that "fast" is relative. I still run shell programs that were written in the 80's, 90's and 2000's without having to change them one iota (I don't think that can be said about BASH but, then, I have not and do not use it but for occasional forays into the dark if night). I value stability, reliability and longevity pretty much above all else (thus the only Linux distribution I've ever used is... guess which). My impression of BASH is that it changes frequently, add-ons, expansions, fiddling and twiddling that I just don't want to deal with -- been bit too many times by vendor utilities and am more than twice shy.
The question, I think, was more about reliability than about size, that's why the recommendation. Thank heaven it wasn't about text editors, eh?
|
|
|
12-16-2013, 11:43 AM
|
#17
|
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
|
Quote:
Originally Posted by gnashley
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.
|
...and never have I had any problem with src2pkg building and using it in a KornShell environment (it's great piece of software, gnashley, and I haven't thanked you often enough for the excellent work).
|
|
|
12-16-2013, 11:49 AM
|
#18
|
Member
Registered: May 2004
Distribution: BSD
Posts: 269
Rep: 
|
Quote:
Originally Posted by tronayne
My impression of BASH is that it changes frequently, add-ons, expansions, fiddling and twiddling that I just don't want to deal with -- been bit too many times by vendor utilities and am more than twice shy.
|
Reminds me of a quote mksh developer Thorsten "mirabilos" Glaser had in his signature about bash:
Yay for having to rewrite other people's Bash scripts because bash
suddenly stopped supporting the bash extensions they make use of
-- Tonnerre Lombard in #nosec
|
|
|
12-16-2013, 12:33 PM
|
#19
|
Member
Registered: Nov 2013
Posts: 748
Rep: 
|
Quote:
Originally Posted by Richard Cranium
Maybe ksh initialization code is faster than bash's, but I wouldn't expect any speedups from switching to ksh. YMMV.
|
afaik bash uses fork() to execute subshells, while ksh does them in the main process
it's not that much overhead but then again any shell is not much overhead on modern computers
Last edited by genss; 12-16-2013 at 12:35 PM.
|
|
|
12-16-2013, 12:54 PM
|
#20
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
It's hard to judge speed on a modern platform with fast, multi-core processors, reasonably large RAM, fast disks and all that sort of thing.
|
Somewhere in the LQ archives is a thread where someone was attempting to change all the slackware init scripts to be fully /bin/ash compatible. To the degree that person was able to do so, he/she/it noticed a significant speed improvement on startup.
Which makes sense, really; the less your shell is supposed to do, the simpler and smaller the code should be.
ksh is a perfectly fine shell. It's just 10x the size of ash. You get a lot for that increase in size, but it may not be stuff that you really need in a script.
|
|
1 members found this post helpful.
|
12-16-2013, 01:07 PM
|
#21
|
LQ Veteran
Registered: May 2008
Posts: 7,112
|
Richard, I think you're remembering the work done by GrapefruiTgirl
|
|
|
12-16-2013, 01:51 PM
|
#22
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
GrapefruiTgirl and tuxdev. I really wanted to implement using dash for init scripts. Our honored friends took two very different approaches to the problem. I took a sort of hybrid idea of the two and made a pretty good system, I think -working for me the last couple of years anyway.
The real problem with the init scripts is in the 'accessory' scripts -some of which are full of bashisms. So, some times where rc.S would have called sh name-of-script it has to be bash name-of-script. and, where rc.S & Co. source other scripts, dash/ash will not accept accept parameters when sourcing, like this:
Code:
. /etc/rc.d/script start
tronayne, thanks for the feedback on src2pkg with ksh.
Back on topic, I think the two main incompatibilities between bash2 and bash3 are the indirect var expansion I mentioned, and the support for arrays. Others were more minor. The use of arrays in slackware init scripts is pretty recent. slack-11.0 or so probably doesn't have any of that.
|
|
|
12-17-2013, 03:42 AM
|
#24
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
I can't compile bash 2.05b.
Quote:
-DCONF_MACHTYPE='"x86_64-slackware-linux-gnu"' -DCONF_VENDOR='"slackware"' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib -O2 -fPIC -c subst.c
In file included from eval.c:33:0:
shell.h:43:21: fatal error: version.h: No such file or directory
compilation terminated.
|
Edit: this was using the same build script from Slackware.org.uk but using the source and patches from slackware 9.1
Last edited by harryhaller; 12-17-2013 at 03:44 AM.
Reason: additional information
|
|
|
12-17-2013, 05:32 AM
|
#25
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
BTW 3.01 has broken nothing - I have to solve the problem of getting 2.05b to compile before I can answer the thread's question.
However, looking at Slackware-9.1's tcpip package
ftp://ftp.heanet.ie/disk1/ftp.slackw...source/n/tcpip
if you open up _tcpip.tar.gz, you'll see that the rc.inet1.conf and rc.inet1 net files there use arrays.
So it'll be interesting to see where bash-2.05b does break the system.
|
|
|
12-17-2013, 11:58 AM
|
#26
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
The tcpip from 9.0 does not use arrays. I've gotten bash-2.05 to compile here, using the patches included back then, plus a couple I created to fix build errors -mktime stalling and a gcc-3.4.6 fix for label at end of compound statement.
I'll put them here. no-time-for-mktime.diff:
Code:
--- ./configure.00 2002-07-16 13:31:47.000000000 +0000
+++ ./configure 2013-12-17 18:28:38.000000000 +0000
@@ -7042,189 +7042,6 @@
fi
done
-echo "$as_me:7045: checking for working mktime" >&5
-echo $ECHO_N "checking for working mktime... $ECHO_C" >&6
-if test "${ac_cv_func_working_mktime+set}" = set; then
- echo $ECHO_N "(cached) $ECHO_C" >&6
-else
- if test "$cross_compiling" = yes; then
- ac_cv_func_working_mktime=no
-else
- cat >conftest.$ac_ext <<_ACEOF
-#line 7054 "configure"
-#include "confdefs.h"
-/* Test program from Paul Eggert and Tony Leneis. */
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
-
-#if HAVE_UNISTD_H
-# include <unistd.h>
-#endif
-
-#if !HAVE_ALARM
-# define alarm(X) /* empty */
-#endif
-
-/* Work around redefinition to rpl_putenv by other config tests. */
-#undef putenv
-
-static time_t time_t_max;
-
-/* Values we'll use to set the TZ environment variable. */
-static const char *const tz_strings[] = {
- (const char *) 0, "TZ=GMT0", "TZ=JST-9",
- "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
-};
-#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
-
-/* Fail if mktime fails to convert a date in the spring-forward gap.
- Based on a problem report from Andreas Jaeger. */
-static void
-spring_forward_gap ()
-{
- /* glibc (up to about 1998-10-07) failed this test. */
- struct tm tm;
-
- /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
- instead of "TZ=America/Vancouver" in order to detect the bug even
- on systems that don't support the Olson extension, or don't have the
- full zoneinfo tables installed. */
- putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
-
- tm.tm_year = 98;
- tm.tm_mon = 3;
- tm.tm_mday = 5;
- tm.tm_hour = 2;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- if (mktime (&tm) == (time_t)-1)
- exit (1);
-}
-
-static void
-mktime_test (now)
- time_t now;
-{
- struct tm *lt;
- if ((lt = localtime (&now)) && mktime (lt) != now)
- exit (1);
- now = time_t_max - now;
- if ((lt = localtime (&now)) && mktime (lt) != now)
- exit (1);
-}
-
-static void
-irix_6_4_bug ()
-{
- /* Based on code from Ariel Faigon. */
- struct tm tm;
- tm.tm_year = 96;
- tm.tm_mon = 3;
- tm.tm_mday = 0;
- tm.tm_hour = 0;
- tm.tm_min = 0;
- tm.tm_sec = 0;
- tm.tm_isdst = -1;
- mktime (&tm);
- if (tm.tm_mon != 2 || tm.tm_mday != 31)
- exit (1);
-}
-
-static void
-bigtime_test (j)
- int j;
-{
- struct tm tm;
- time_t now;
- tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
- now = mktime (&tm);
- if (now != (time_t) -1)
- {
- struct tm *lt = localtime (&now);
- if (! (lt
- && lt->tm_year == tm.tm_year
- && lt->tm_mon == tm.tm_mon
- && lt->tm_mday == tm.tm_mday
- && lt->tm_hour == tm.tm_hour
- && lt->tm_min == tm.tm_min
- && lt->tm_sec == tm.tm_sec
- && lt->tm_yday == tm.tm_yday
- && lt->tm_wday == tm.tm_wday
- && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
- == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
- exit (1);
- }
-}
-
-int
-main ()
-{
- time_t t, delta;
- int i, j;
-
- /* This test makes some buggy mktime implementations loop.
- Give up after 60 seconds; a mktime slower than that
- isn't worth using anyway. */
- alarm (60);
-
- for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
- continue;
- time_t_max--;
- delta = time_t_max / 997; /* a suitable prime number */
- for (i = 0; i < N_STRINGS; i++)
- {
- if (tz_strings[i])
- putenv (tz_strings[i]);
-
- for (t = 0; t <= time_t_max - delta; t += delta)
- mktime_test (t);
- mktime_test ((time_t) 60 * 60);
- mktime_test ((time_t) 60 * 60 * 24);
-
- for (j = 1; 0 < j; j *= 2)
- bigtime_test (j);
- bigtime_test (j - 1);
- }
- irix_6_4_bug ();
- spring_forward_gap ();
- exit (0);
-}
-_ACEOF
-rm -f conftest$ac_exeext
-if { (eval echo "$as_me:7203: \"$ac_link\"") >&5
- (eval $ac_link) 2>&5
- ac_status=$?
- echo "$as_me:7206: \$? = $ac_status" >&5
- (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
- { (eval echo "$as_me:7208: \"$ac_try\"") >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- echo "$as_me:7211: \$? = $ac_status" >&5
- (exit $ac_status); }; }; then
- ac_cv_func_working_mktime=yes
-else
- echo "$as_me: program exited with status $ac_status" >&5
-echo "$as_me: failed program was:" >&5
-cat conftest.$ac_ext >&5
-ac_cv_func_working_mktime=no
-fi
-rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
-fi
-fi
-echo "$as_me:7223: result: $ac_cv_func_working_mktime" >&5
-echo "${ECHO_T}$ac_cv_func_working_mktime" >&6
-if test $ac_cv_func_working_mktime = no; then
- LIBOBJS="$LIBOBJS mktime.$ac_objext"
-fi
for ac_header in libintl.h
do
gcc-3.4.6.diff:
Code:
--- ./lib/malloc/malloc.c.01 2002-06-21 19:16:49.000000000 +0000
+++ ./lib/malloc/malloc.c 2013-12-17 18:35:56.000000000 +0000
@@ -878,7 +878,7 @@
nextf[nunits] = p;
busy[nunits] = 0;
-free_return:
+free_return:;
#ifdef MALLOC_STATS
_mstats.nmalloc[nunits]--;
And for good measure, bash.src2pkg:
Code:
#!/bin/bash
## src2pkg script for: bash
## Auto-generated by src2pkg-2.91
## src2pkg - Copyright 2005-2013 Gilbert Ashley <amigo@ibilio.org>
SOURCE_NAME='bash-2.05b.tar.gz'
NAME='bash' # Use ALT_NAME to override guessed value
VERSION='2.05b' # Use ALT_VERSION to override guessed value
# ARCH=''
# BUILD='1'
# PRE_FIX='usr'
# Any extra options go here:
# EXTRA_CONFIGS=""
PATCHLIST='bash-patches/bash205b-001.gz
bash-patches/bash205b-002.gz
bash-patches/bash205b-003.gz
bash-patches/bash205b-004.gz
bash-patches/bash205b-005.gz
bash-patches/bash205b-006.gz
bash-patches/bash205b-007.gz
bash-patches/no-time-for-mktime.diff
bash-patches/gcc-3.4.6.diff
'
# Optional function replaces configure_source, compile_source, fake_install
# To use, uncomment and write/paste CODE between the {} brackets.
# build() { CODE }
# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;
# Execute the named packaging steps:
pre_process
find_source
make_dirs
unpack_source
fix_source_perms
configure_source #
compile_source # If used, the 'build' function replaces these 3
fake_install #
fix_pkg_perms
strip_bins
create_docs
compress_man_pages
make_description
make_doinst
make_package
post_process
|
|
1 members found this post helpful.
|
12-17-2013, 02:45 PM
|
#27
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
@Gnashley, that compiled well with your script - and didn't compile with the other build scripts.
Before installing, I've made the following changes to the script so that it installs to /bin and uses the doinstall.sh from the distribution build:
bash.src2pkg:
Code:
make_description
make_doinst
mkdir -p $PKG/bin
mv $PKG/usr/bin/bash $PKG/bin/bash2.new
strip $PKG/bin/bash2.new
chown -R root.bin $PKG/bin
make_package
post_process
The doinst.sh for the distribution build is
Code:
if [ -r bin/bash ]; then
mv bin/bash bin/bash.old
fi
mv bin/bash2.new bin/bash
if [ -f bin/bash.old ]; then
rm -f bin/bash.old
fi
if [ ! -r etc/shells ]; then
touch etc/shells
chmod 644 etc/shells
fi
if fgrep "/bin/bash" etc/shells 1> /dev/null 2> /dev/null ; then
true
else
echo "/bin/bash" >> etc/shells
fi
( cd usr/bin ; rm -rf bash )
( cd usr/bin ; ln -sf /bin/bash bash )
I've already tested bash-2.05b "stand alone" in a terminal and ran a script which uses arrays and it ran ok.
Last edited by harryhaller; 12-17-2013 at 04:09 PM.
|
|
|
12-17-2013, 04:13 PM
|
#28
|
Member
Registered: Sep 2004
Distribution: Slackware-14.2
Posts: 472
Original Poster
Rep: 
|
It's installed and nothing's broke
One would have to go back to an earlier version to get the real bourne shell and that version probably would be so much like sh that it would lack the user friendliness.
In any case, the greatest problem has been getting these old versions to compile and I, as you have seen, have no expertise in that.
|
|
|
12-18-2013, 01:33 AM
|
#30
|
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928
|
Opps, yeah I forgot about the special doinst.sh.
As to the non-bash init scripts, you can find my more complete implementation here:
http://distro.ibiblio.org/amigolinux...vinit-scripts/
The 'child' scripts are installed by their packages, so look around in that SOURCE tree for them. Since I use a separate shebang '/bin/initsh', you can set it up to use any shell you like just by linking, for instance:
ln -sf /bin/dash /bin/initsh
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 05:30 PM.
|
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
|
|