It is impossible to formulate sane ABI based on
size of ulong because it can be 32-bit or 64-bit.
Basically it means that you cannot portably use
more that 32 option chars in one call anyway...
Make it explicit.
The minimal version got a couple hundred bytes bigger, partly because it's
broken into more functions but mostly because it now dynamically reallocates
and frees everything with no hard-coded limits. (I thought about making
that optional, but there's a limit to what I can debug and maintain. It
should still be reasonably NOMMU friendly, the allocations are small and
short lived, and shouldn't contribute noticeably to long-term memory
fragmentation.)
applet list yet (and won't be until it can replace lash, I'm not having five
shells in menuconfig at once), but you can build it with scripts/individual
and mostly this is checked in so I can bloatcheck future versions against it
easily....
This is about as small as a shell can get and still be a shell.
were using "1" as one of the arguments anyway, and as for the rest a multiply
and a push isn't noticeably bigger than pushing two arguments on the stack.
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes... General cleanup pass. What I've
been doing for the last couple days.
And it conflicts! I've removed httpd.c from this checkin due to somebody else
touching that file. It builds for me. I have to catch a bus. (Now you know
why I'm looking forward to Mercurial.)
untangle them:
Rewrite u_signal_names() into get_signum() and get_signame(), plus trim the
signal list to that required by posix (they can specify the numbers for
the rest if they really need them). (This is preparatory cleanup for adding
a timeout applet like Roberto Foglietta wants.)
Export the itoa (added due to Denis Vlasenko, although it's not quite his
preferred implementation) from xfuncs.c so it's actually used, and remove
several other redundant implementations of itoa and utoa() in the tree.
moved the contents of libbb/bb_echo.c back into coreutils/echo.c,
which is a more reasonable place for them than libbb. this
forces anyone who wants echo and test to be builtin to ash to
also have them available as applets. their cost is very small,
and the number of people who wouldn't want them as applets is
also very small.
added warning about shell builtins vs. CONFIG_FEATURE_SH_STANDALONE_SHELL,
which conflicts with their use.
thanks to nathanael copa for debugging help.
some string size optimization in test.c may have been lost with
this commit, but this is a good new baseline.
case labels that are emitted by gcc4. rearrange macros to
eliminate these extra case labels entirely (since the optimizer
may no longer do it for us). eliminate static BUFSIZ character
deletion buffer -- malloc it, and make it much much smaller.
in the menu hierarchy or else make allnoconfig winds up leaving whatever the
select points to as "y". (In this case, "make allnoconfig" is leaving
CONFIG_TEST as "y".)
Summary 0000242: ash: read -t broken
this also implements -n and -s options to read. (they're configured
together because most of their code is in common, and separating them
seemed silly.
If we exec /proc/self/exe and only fall back to /bin/busybox if /proc isn't
there, then we have a reasonable chance of having the standalone shell work
even if busybox isn't installed in /bin on the system in question.
Still won't work in a chroot environment, but it's an improvement.
Hi!
I've created a patch to busybox' build system to allow building it in
separate tree in a manner similar to kbuild from kernel version 2.6.
That is, one runs command like
'make O=/build/some/where/for/specific/target/and/options'
and everything is built in this exact directory, provided that it exists.
I understand that applyingc such invasive changes during 'release
candidates' stage of development is at best unwise. So, i'm currently
asking for comments about this patch, starting from whether such thing
is needed at all to whether it coded properly.
'make check' should work now, and one make creates Makefile in build
directory, so one can run 'make' in build directory after that.
One possible caveat is that if we build in some directory other than
source one, the source directory should be 'distclean'ed first.
egor
CONFIG_FEATURE_COMMAND_EDITING was defined *and*
CONFIG_FEATURE_COMMAND_TAB_COMPLETION was undefined.
Vladimir N. Oleynik writes:
Its declare always, also if CONFIG_FEATURE_COMMAND_TAB_COMPLETION
undefined.
Patch to CVS version attached.
--w
vodz
This patch makes msh handle variable expansion within backticks more
correctly.
Current behaviour (wrong):
--------------------------
BusyBox v1.00-rc3 (2004.08.26-11:51+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
$ A='`echo hello`'
$ echo $A
`echo hello`
$ echo `echo $A`
hello
$
New behaviour (correct):
------------------------
BusyBox v1.00-rc3 (2004.08.26-11:51+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.
$ A='`echo hello`'
$ echo $A
`echo hello`
$ echo `echo $A`
`echo hello`
$
The current behaviour (wrong according to standards) was actually my
fault. msh handles backticks by executing a subshell (which makes it
work on MMU-less systems). Executing a subshell makes it hard to only
expand variables once in the parent. Therefore I export all variables
that will be expanded within the backticks and let the subshell handle
the expansion instead.
The bug was found while searching for security leaks in CGI-scripts.
Current behaviour of msh makes it easy to expand backticks by mistake
in $QUERY_STRING. I recommend appling the patch before release of bb
1.00.
/Jonas
On Wed Aug 18, 2004 at 06:52:57PM +0800, Matt Johnston wrote:
> I've come across some strange-seeming behaviour when running programs
> under Busybox (1.0.0-rc3) ash. If the child process sets stdin to be
> non-blocking and then exits, the parent ash will also exit. A quick strace
> shows that a subsequent read() from stdin returns EAGAIN (as would be
> expected):
Thanks!
Patch attached.
--w
vodz
This bug is in busybox 1.0.0-rc2. When using lash exec
builtin with redirection, the opened file fd keep increasing.
For example, please try the following command with lash.
ls -al /proc/<lash pid>/fd
exec /bin/sh 2>/dev/null
ls -al /proc/<lash pid>/fd
The last 'ls' command output will look like this. The fd
number 4 shouldn't exist.
lrwx------ 1 501 100 64 Aug 13 13:56 4 -> /dev/pts/5
l-wx------ 1 501 100 64 Aug 13 13:56 2 -> /dev/null
lrwx------ 1 501 100 64 Aug 13 13:56 1 -> /dev/pts/5
lrwx------ 1 501 100 64 Aug 13 13:56 0 -> /dev/pts/5
dr-xr-xr-x 3 501 100 0 Aug 13 13:56 ..
dr-x------ 2 501 100 0 Aug 13 13:56 .
This one-line patch fix this problem by setting CLOEXEC flag for
squirrel fd. Please apply.
Joe.C
A question was posted a month ago by Mark Alamo to see if others had
problems with sourcing subscripts within msh. We asked his firm to fix the
msh.c bug he described because we didn't have enough time to do it
ourselves.
When msh.c is executing a compound statement and there is a . command to
source another script file, msh.c will not execute the subscript until it's
completed executing the rest of the compound statement.
His example was this:
Echo "Start" ; . ./subA; echo "mid" ; . ./subB ; echo "end"
subA and subB execute AFTER end is printed in reverse order. The same is
true if the sourced files are inside an if else fi, case esac, or any
compound statement.
Attached is a patch to msh.c. It fixes the problem. Cd to the root of your
busybox tree and execute "patch -p1 < msh.c.patch"
Unfortunately, I won't have more time to work on this so I hope that there
aren't any problems!
Michael Leibow
Senior Software Engineer
Belkin Corporation
With job control enabled, ash fails to tcsetpgrp back to initialpgrp
upon exit. exitshell() should call setjobctl(0) to do this.
Context: I am using a lightweight menu system (replimenu[.sf.net]) on my
console, which invokes "/bin/sh -i -c /bin/login", where /bin/sh and
/bin/login are busybox applets. /bin/sh is ash, with
CONFIG_ASH_JOB_CONTROL=y as the sole suboption. The shell of the user
concerned (nobody) is also /bin/sh (ash). When the user /bin/sh exits
(and thereby login and its parent sh), replimenu receives EIO when it
tries to read from the terminal.
The updated patch adds a config option to explicitely enable 64 bit
arithmetic.
Also it removes the arith prototype from libbb.h as it is not used
outside of ash.
Bastian
this patch has been slightly modified by Erik for cleanliness.
This is a bulk spelling fix patch against busybox-1.00-pre10.
If anyone gets a corrupted copy (and cares), let me know and
I will make alternate arrangements.
Erik - please apply.
Authors - please check that I didn't corrupt any meaning.
Package importers - see if any of these changes should be
passed to the upstream authors.
I glossed over lots of sloppy capitalizations, missing apostrophes,
mixed American/British spellings, and German-style compound words.
What is "pretect redefined for test" in cmdedit.c?
Good luck on the 1.00 release!
- Larry
He,
there is a bug in HUSH's handling of "if" / "elif" commands:
$ if true
> then
> echo 1
> elif
> true
> then
> echo 2
> elif
> true
> then
> echo 3
> else
> echo 4
> fi
1
2
3
$
The same bug exists in all versions of HUSH from BB v0.60.x up to and
including v1.00-pre9. The attached patch fixes this:
$ if true
> then
> echo 1
> elif
> true
> then
> echo 2
> elif
> true
> then
> echo 3
> else
> echo 4
> fi
1
$
Best regards,
Wolfgang Denk
Just upgraded from 0.6 to 1.00-pre8
Dot command handling handled args correctly (same as bash) in 0.60,
but failed in 1.00:
I fixed this by reverting the dotcmd function back to previous 0.60
instantiation,
please consider using the older version.
Thanks
Peter
It looks like latest uClibc defines ARCH_HAS_MMU, but a few busybox files
test UCLIBC_HAS_MMU, resulting in vfork() getting called instead of
fork(), etc.
Patch below. Only tested for lash.
Cheers,
-Jamie
have checked in. Vladimir writes:
Your patch have many problem.
1. You always added + time(). This cannot reset RANDOM=value for debuging
with
replay sequential.
2. Hmm. I examine bash 2.04 source. This pseudorandom generator use low bits
of
counter value. You use high bits. This make bad pseudorandom values after
have
0-value. For example, if + time() do remove, your generator always return 0
after
first generate 0.
3. Memory leak per call. Use ash-unlike unecessary bb_strdup function.
4. Unsupport show last $RANDOM value for "set" and "export" command.
5. Bloat code. Busybox-unlike patch - added unstandart feature as default
hardcode.
Last patch attached.
Erik, why you apply Paul patch with have 5-th point problem? :(
Last patch have ash change xwrite() to fresh libbb/bb_full_write interfase
(haved loop after EINTR).
--w
vodz
Here's a follow-up replacement to the patch I sent earlier, this adjusts some
of the semantics of the dynamic variable setting. Namely, dynamic vars can hook
a set handler (which RANDOM uses to adjust the seed). They'll only lose their
dynamic status if they're unset.
I've used the same approach that bash does to come up with the random number,
mostly just for consistency.
For example:
$ echo $RANDOM
13759
$ echo $RANDOM
20057
$ echo $RANDOM
1502
$ export RANDOM=42
$ echo $RANDOM
24179
$ echo $RANDOM
2046
$ unset RANDOM
$ echo $RANDOM
$ export RANDOM=42
$ echo $RANDOM
42
$
- declare applet_using as static from applets.c
- small correction to cmdedit,
previous version cleared history after Ctrl-C
- small spelling correction (by Friedrich Lobenstock)
Richard,
>I have a problem, which I can reproduce now. I am using pre7 version of
>busybox, and the tab completion works fine. I mean, with an empty command
>line I press the TAB twice, and ash shows me the available commands. But
>when i process the profile file below, as
> $ . /etc/profile
>then it stops working, and the double-tab lists the directories available
>from the cwd, and not the commands. Has someone else meet this problem
>before, or am i doing something wrong?
>
>This is my '/etc/profile':
>- ---
># System profile
>
>PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
>export PATH
>trap ":" INT QUIT TERM
>
>export PS1="\h \w # "
Thanks. Patch attached.
--w
vodz
- synced with dash 0.4.21
- better handle trap "cmds..." SIGINT (strange, i make bad hack for ash
and cmdedit, but this work only with this...)
- may be haven`t problem with Ctrl-D
the busybox menuconfig triggered my "inacceptable number of spelling mistakes"
upper level, so I decided to make a patch ;-)
I also improved some wording to describe some things in a better way.
Many thanks for an incredible piece of software!
Andreas Mohr, random OSS developer
The construct certain vintages of GCC (the one I have trouble
with is 3.2.3) have trouble with looks like the following:
static struct st a;
static struct st *p = &a;
struct st { int foo; };
static void init(void) { a.foo = 0; }
The problem disappears if we move the struct declaration up to
let the compiler know the shape of the struct before the first
definition uses it, like this:
struct st { int foo; }; /* this has been moved up */
static struct st a;
static struct st *p = &a;
static void init(void) { a.foo = 0; }
"If the shell is compiled with -DJOBS, this is all fine -- find wasn't
stopped (it was killed), so it correctly uses WTERMSIG instead of WSTOPSIG.
However, if the shell _isn't_ compiled with -DJOBS (which it isn't in d-i),
only WSTOPSIG is used, which extracts the high byte instead of the low
byte from the status code. Since the status code is 13 (SIGPIPE), "st"
suddenly gets the value 0, which is equivalent to SIGEXIT. Thus, ash prints
out "EXIT" on find's exit."
unless it had #!/bin/sh in the first line
"It correctly locates the script, tries to execute it via execve which
fails. After that it tries to hand it over to /bin/sh which fails too,
since ash
- neither provides the absolute pathname to /bin/sh
- nor tries to lookup the script via PATH if called as "sh script"
"
Last patch have synced form Manuel Nova III xxreadtoken() function,
corrected (C) form dash debian/copyright, removed my small mistake
with IFS_BROKEN (thanks by Herbert), and synced cmdedit.c from
current CVS (removed libc5 support, your email correction, my (C) year
corertion).
Hello all,
This patch adds more "Help" text to the config system. Almost
all applets now have a help entry. Also, I cleaned up the spacing of
the existing text so that things are consistent. This patch is against
this morning's CVS.
Thomas Cameron
CEI Systems, Inc.
modified Kbuild system I put into uClibc. With this, there should be no more
need to modify Rules.mak since I've moved all the interesting options into the
config system. I think I've got everything updated, but you never know, I may
have made some mistakes, so watch closely.
-Erik
config system
- added a new config option to allow persistant history lists. This is
currently only used by ash, but the calls ({load,save}_history) could
be added to the other shells as well.
HP iPAQ. Sometimes we get a SIGWINCH and want to print the prompt, although
the prompt is not yet initialised (0) .. so just don't print a prompt
as long as the prompt string is 0
#49: I found one memory overflow and memory leak in "ln" applet.
Last patch reduced also 54 bytes. ;)
#50: I found bug in loginutils/Makefile.in.
New patch have also new function to libbb and
aplied this to applets and other cosmetic changes.
When alias support is not configured, ash believes that command parameters
that look like dd's "if=/dev/zero" are requests to set a temporary
environment variable whilst dd is running, even though it appears after the
command name. This is caused by the re-use of the checkalias global variable
to indicate when both alias checking and environment variable checking. The
failure to reset this flag is due to the reset action being performed only
inside the feature check CHECK_ASH_ALIAS. Hence ash works as expected when
aliases are configured in, and fails when not.
Example script using 'date' with different settings of TZ:
# TZ=Europe/London
# export TZ
# date
Thu May 30 17:18:49 BST 2002
# TZ=America/New_York date
Thu May 30 12:19:10 EDT 2002
# date
Thu May 30 17:19:12 BST 2002
# date TZ=America/New_York
Thu May 30 12:19:30 EDT 2002 <----- wrong, should be BST time (or error!)
# date
Thu May 30 17:19:35 BST 2002
Attached is a patch against revision 1.52 of ash.c which moves the checks so
that checkalias is updated regardless of whether CONFIG_ASH_ALIAS is set.
With this patch applied, the command shown above which should generate an
error does generate an error.
I have tested this patch with the 'dd' command too and that now works
correctly.
the busybox development tree. This eliminates the use of recursive make, and
once again allows us to run 'make' in a subdirectory with the expected result.
And things are now much faster too. Greatly improved IMHO...
-Erik
This diff does 2 things:
1) removes an unnecessary function. saves 64 bytes on i386
2) allows you to disable checking of mail (actually, it's now disabled
by default). this would be a nice CML1 option, but for now it's a
#(define|undef) in the C file like the other internal ash options.
this saves an additional 352 bytes if you leave mail disabled.
so that the table implementations of copynode, calcsize, and cmdtxt are
used. Hopefully this will result in wider testing. ;-) If it breaks,
just unset the appropriate defines.
and copynode() table implementations. Commit the fix but keep them disabled
until others check them out. Uncomment "//#define CMDTXT_TABLE",
"//#define CALCSIZE_TABLE", and "//#define COPYNODE_TABLE" to try them out.
Saves over 600 bytes on i386.
math suport, cleaner math syntax error checking, moves redundant signal
string tables (from kill and ash) into libbb and provides a few
cleanups elsewhere.
was written by Aaron Lehmann <aaronl@vitelus.com> for busybox. This
patch makes a few trivial changes to Aaron's code so that it can be
used (in theory) by the other shells as well...
-Erik
1) ping cleanup (compile fix from this patch already applied).
2) traceroute call not spare ntohl() now (and reduce size);
3) Fix for functions not declared static in insmod, ash, vi and mount.
4) a more simple API cmdedit :))
5) adds "stopped jobs" warning to ash on Ctrl-D and fixes "ignoreeof" option
6) reduce exporting library function index->strchr (traceroute), bzero->memset (syslogd)
handles all the basic stuff (for, case/esac, while, if/then/else), and
is very small (adds just 38k on x86). It is not as rigorously correct
about Bourne semantics as bash, but for most things it is quite
workable. There is still some work to be done to further shrink it (it
has its own globbing functions instead of using the libc ones, for
example), but it is quite usable as is.
-Erik