aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure4
-rwxr-xr-xscripts/bloatcheck4
-rwxr-xr-xscripts/change.sh6
-rwxr-xr-xscripts/findglobals.sh2
-rwxr-xr-xscripts/genconfig.sh33
-rwxr-xr-xscripts/install.sh17
-rwxr-xr-xscripts/make.sh45
-rwxr-xr-xscripts/mcm-buildall.sh30
-rw-r--r--scripts/portability.sh2
-rwxr-xr-xscripts/record-commands2
-rwxr-xr-xscripts/single.sh8
11 files changed, 78 insertions, 75 deletions
diff --git a/configure b/configure
index 0b6501fc..23dd687d 100755
--- a/configure
+++ b/configure
@@ -1,10 +1,10 @@
-#!/bin/bash
+#!/bin/sh
# This sets environment variables used by scripts/make.sh
# People run ./configure out of habit, so do "defconfig" for them.
-if [ "$(basename "$0")" == configure ]
+if [ "${0##*/}" = configure ]
then
echo "Assuming you want 'make defconfig', but you should probably check the README."
make defconfig
diff --git a/scripts/bloatcheck b/scripts/bloatcheck
index fff4690f..30492c64 100755
--- a/scripts/bloatcheck
+++ b/scripts/bloatcheck
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
if [ $# -ne 2 ]
then
@@ -40,7 +40,7 @@ do_bloatcheck()
fi
SIZE=$(printf "%d" "0x$b")
- if [ "$a" == "-" ]
+ if [ "$a" = "-" ]
then
OLD=$(($OLD+$SIZE))
SIZE=$((-1*$SIZE))
diff --git a/scripts/change.sh b/scripts/change.sh
index 99dcfde9..b1fa62a0 100755
--- a/scripts/change.sh
+++ b/scripts/change.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# build each command as a standalone executable
@@ -14,8 +14,8 @@ mkdir -p "$PREFIX" || exit 1
for i in $(generated/instlist | egrep -vw "sh|help")
do
- echo -n " $i" &&
+ printf ' %s' "$i" &&
scripts/single.sh $i > /dev/null 2>$PREFIX/${i}.bad &&
- rm $PREFIX/${i}.bad || echo -n '*'
+ rm $PREFIX/${i}.bad || printf '*'
done
echo
diff --git a/scripts/findglobals.sh b/scripts/findglobals.sh
index 2c63164b..9455bc61 100755
--- a/scripts/findglobals.sh
+++ b/scripts/findglobals.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Quick and dirty check to see if anybody's leaked global variables.
# We should have this, toy_list, toybuf, and toys.
diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh
index 955c82cd..b97eab66 100755
--- a/scripts/genconfig.sh
+++ b/scripts/genconfig.sh
@@ -1,11 +1,11 @@
-#!/bin/bash
+#!/bin/sh
# This has to be a separate file from scripts/make.sh so it can be called
# before menuconfig. (It's called again from scripts/make.sh just to be sure.)
mkdir -p generated
-source scripts/portability.sh
+. scripts/portability.sh
probecc()
{
@@ -18,8 +18,8 @@ probesymbol()
{
probecc $2 2>/dev/null && DEFAULT=y || DEFAULT=n
rm a.out 2>/dev/null
- echo -e "config $1\n\tbool" || exit 1
- echo -e "\tdefault $DEFAULT\n" || exit 1
+ printf 'config %s\n\tbool\n' "$1" || exit 1
+ printf '\tdefault %s\n\n' "$1" || exit 1
}
probeconfig()
@@ -28,7 +28,7 @@ probeconfig()
# llvm produces its own really stupid warnings about things that aren't wrong,
# and although you can turn the warning off, gcc reacts badly to command line
# arguments it doesn't understand. So probe.
- [ -z "$(probecc -Wno-string-plus-int <<< \#warn warn 2>&1 | grep string-plus-int)" ] &&
+ [ -z "$(echo '#warn' | probecc -Wno-string-plus-int warn 2>&1 | grep string-plus-int)" ] &&
echo -Wno-string-plus-int >> generated/cflags
# Probe for container support on target
@@ -92,7 +92,7 @@ EOF
#include <unistd.h>
int main(int argc, char *argv[]) { return fork(); }
EOF
- echo -e '\tdepends on !TOYBOX_FORCE_NOMMU'
+ printf '\tdepends on !TOYBOX_FORCE_NOMMU\n'
probesymbol TOYBOX_PRLIMIT << EOF
#include <sys/types.h>
@@ -155,17 +155,18 @@ PENDING=
toys toys/*/*.c | (
while IFS=":" read FILE NAME
do
- [ "$NAME" == help ] && continue
- [ "$NAME" == install ] && continue
- [ "$NAME" == sh ] && FILE="toys/*/*.c"
- echo -e "$NAME: $FILE *.[ch] lib/*.[ch]\n\tscripts/single.sh $NAME\n"
- echo -e "test_$NAME:\n\tscripts/test.sh $NAME\n"
- [ "${FILE/pending//}" != "$FILE" ] &&
+ [ "$NAME" = help ] && continue
+ [ "$NAME" = install ] && continue
+ [ "$NAME" = sh ] && FILE="toys/*/*.c"
+ printf '%s: %s *.[ch] lib/*.[ch]\n\tscripts/single.sh %s\n\n' \
+ "$NAME" "$FILE" "$NAME"
+ printf 'test_%s:\n\tscripts/test.sh %s\n\n' "$NAME" "$NAME"
+ [ "${FILE#*pending}" != "$FILE" ] &&
PENDING="$PENDING $NAME" ||
WORKING="$WORKING $NAME"
done &&
-echo -e "clean::\n\t@rm -f $WORKING $PENDING" &&
-echo -e "list:\n\t@echo $(echo $WORKING | tr ' ' '\n' | sort | xargs)" &&
-echo -e "list_pending:\n\t@echo $(echo $PENDING | tr ' ' '\n' | sort | xargs)" &&
-echo -e ".PHONY: $WORKING $PENDING" | $SED 's/ \([^ ]\)/ test_\1/g'
+printf 'clean::\n\t@rm -f %s %s\n' "$WORKING" "$PENDING" &&
+printf 'list:\n\t@echo %s\n' "$(echo $WORKING | tr ' ' '\n' | sort | xargs)" &&
+printf 'list_pending:\n\t@echo %s\n' "$(echo $WORKING | tr ' ' '\n' | sort | xargs)" &&
+echo ".PHONY: $WORKING $PENDING" | $SED 's/ \([^ ]\)/ test_\1/g'
) > .singlemake
diff --git a/scripts/install.sh b/scripts/install.sh
index adf36027..ce486260 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/bin/sh
# Grab default values for $CFLAGS and such.
-source ./configure
+. ./configure
[ -z "$PREFIX" ] && PREFIX="/usr/toybox"
@@ -12,19 +12,19 @@ LONG_PATH=""
while [ ! -z "$1" ]
do
# Create symlinks instead of hardlinks?
- [ "$1" == "--symlink" ] && LINK_TYPE="-s"
+ [ "$1" = "--symlink" ] && LINK_TYPE="-s"
# Uninstall?
- [ "$1" == "--uninstall" ] && UNINSTALL=Uninstall
+ [ "$1" = "--uninstall" ] && UNINSTALL=Uninstall
# Delete destination command if it exists?
- [ "$1" == "--force" ] && DO_FORCE="-f"
+ [ "$1" = "--force" ] && DO_FORCE="-f"
# Use {,usr}/{bin,sbin} paths instead of all files in one directory?
- [ "$1" == "--long" ] && LONG_PATH="bin/"
+ [ "$1" = "--long" ] && LONG_PATH="bin/"
# Symlink host toolchain binaries to destination to create cross compile $PATH
- [ "$1" == "--airlock" ] && AIRLOCK=1
+ [ "$1" = "--airlock" ] && AIRLOCK=1
shift
done
@@ -130,8 +130,7 @@ do
ln -sf "$j" "$FALLBACK/$i" || exit 1
fi
- X=$[$X+1]
- FALLBACK="$PREFIX/fallback-$X"
+ FALLBACK="$PREFIX/fallback-$((X += 1))"
done
if [ ! -f "$PREFIX/$i" ]
diff --git a/scripts/make.sh b/scripts/make.sh
index 5b2d5d81..61b58329 100755
--- a/scripts/make.sh
+++ b/scripts/make.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Grab default values for $CFLAGS and such.
@@ -16,8 +16,7 @@ fi
export LANG=c
export LC_ALL=C
-set -o pipefail
-source scripts/portability.sh
+. scripts/portability.sh
[ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=.config
[ -z "$OUTNAME" ] && OUTNAME=toybox"${TARGET:+-$TARGET}"
@@ -31,7 +30,7 @@ UNSTRIPPED="generated/unstripped/$(basename "$OUTNAME")"
DOTPROG=
do_loudly()
{
- [ ! -z "$V" ] && echo "$@" || echo -n "$DOTPROG"
+ [ ! -z "$V" ] && echo "$@" || printf '%s' "$DOTPROG"
"$@"
}
@@ -60,7 +59,7 @@ fi
if isnewer generated/newtoys.h toys
then
- echo -n "generated/newtoys.h "
+ printf 'generated/newtoys.h '
echo "USE_TOYBOX(NEWTOY(toybox, NULL, TOYFLAG_STAYROOT))" > generated/newtoys.h
$SED -n -e 's/^USE_[A-Z0-9_]*(/&/p' toys/*/*.c \
@@ -83,9 +82,9 @@ BUILD="$(echo ${CROSS_COMPILE}${CC} $CFLAGS -I . $OPTIMIZE $GITHASH)"
LIBFILES="$(ls lib/*.c | grep -v lib/help.c)"
TOYFILES="lib/help.c main.c $TOYFILES"
-if [ "${TOYFILES/pending//}" != "$TOYFILES" ]
+if [ "${TOYFILES#*pending}" != "$TOYFILES" ]
then
- echo -e "\n\033[1;31mwarning: using unfinished code from toys/pending\033[0m"
+ printf '\n\033[1;31mwarning: using unfinished code from toys/pending\033[0m\n'
fi
genbuildsh()
@@ -106,10 +105,10 @@ genbuildsh()
echo '$BUILD $FILES $LINK'
}
-if ! cmp -s <(genbuildsh 2>/dev/null | head -n 6 ; echo LINK="'"$LDOPTIMIZE $LDFLAGS) \
- <(head -n 7 generated/build.sh 2>/dev/null | $SED '7s/ -o .*//')
+if [ "$(genbuildsh 2>/dev/null | head -n 6 ; echo LINK="'"$LDOPTIMIZE $LDFLAGS)" != \
+ "$(head -n 7 generated/build.sh 2>/dev/null | $SED '7s/ -o .*//')" ]
then
- echo -n "Library probe"
+ printf 'Library probe'
# We trust --as-needed to remove each library if we don't use any symbols
# out of it, this loop is because the compiler has no way to ignore a library
@@ -122,7 +121,7 @@ then
echo "int main(int argc, char *argv[]) {return 0;}" | \
${CROSS_COMPILE}${CC} $CFLAGS $LDFLAGS -xc - -o generated/libprobe $LDASNEEDED -l$i > /dev/null 2>/dev/null &&
echo -l$i >> generated/optlibs.dat
- echo -n .
+ printf .
done
rm -f generated/libprobe
echo
@@ -185,7 +184,7 @@ make_flagsh()
echo "#define NEWTOY(aa,bb,cc) aa $I bb"
echo '#define OLDTOY(...)'
- if [ "$I" == A ]
+ if [ "$I" = A ]
then
cat generated/config.h
else
@@ -215,13 +214,13 @@ make_flagsh()
if isnewer generated/flags.h toys "$KCONFIG_CONFIG"
then
- echo -n "generated/flags.h "
+ printf 'generated/flags.h '
make_flagsh
fi
# Extract global structure definitions and flag definitions from toys/*/*.c
-function getglobals()
+getglobals()
{
for i in toys/*/*.c
do
@@ -230,13 +229,13 @@ function getglobals()
-e 's/^GLOBALS(/struct '"$NAME"'_data {/' \
-e 's/^)/};/' -e 'p' $i)"
- [ ! -z "$DATA" ] && echo -e "// $i\n\n$DATA\n"
+ [ ! -z "$DATA" ] && printf '// %s\n\n%s\n\n' "$i" "$DATA"
done
}
if isnewer generated/globals.h toys
then
- echo -n "generated/globals.h "
+ printf 'generated/globals.h '
GLOBSTRUCT="$(getglobals)"
(
echo "$GLOBSTRUCT"
@@ -255,7 +254,7 @@ fi
if isnewer generated/tags.h toys
then
- echo -n "generated/tags.h "
+ printf 'generated/tags.h '
$SED -n '/TAGGED_ARRAY(/,/^)/{s/.*TAGGED_ARRAY[(]\([^,]*\),/\1/;p}' \
toys/*/*.c lib/*.c | generated/mktags > generated/tags.h
@@ -273,7 +272,7 @@ fi
[ ! -z "$NOBUILD" ] && exit 0
-echo -n "Compile $OUTNAME"
+printf 'Compile %s' "$OUTNAME"
[ ! -z "$V" ] && echo
DOTPROG=.
@@ -286,7 +285,7 @@ if [ ! -e "$X" ] || [ ! -z "$(find toys -name "*.h" -newer "$X")" ]
then
rm -rf generated/obj && mkdir -p generated/obj || exit 1
else
- rm -f generated/obj/{main,lib_help}.o || exit 1
+ rm -f generated/obj/main.o generated/obj/lib_help.o || exit 1
fi
# build each generated/obj/*.o file in parallel
@@ -299,9 +298,10 @@ CLICK=
for i in $LIBFILES click $TOYFILES
do
- [ "$i" == click ] && CLICK=1 && continue
+ [ "$i" = click ] && CLICK=1 && continue
- X=${i/lib\//lib_}
+ X="$i"
+ [ "${X#*lib/}" = "$X" ] || X="${X%%lib/*}lib_${X#*lib/}"
X=${X##*/}
OUT="generated/obj/${X%%.c}.o"
LNKFILES="$LNKFILES $OUT"
@@ -309,7 +309,8 @@ do
# $LIBFILES doesn't need to be rebuilt if older than .config, $TOYFILES does
# ($TOYFILES contents can depend on CONFIG symbols, lib/*.c never should.)
- [ "$OUT" -nt "$i" ] && [ -z "$CLICK" -o "$OUT" -nt "$KCONFIG_CONFIG" ] &&
+ [ -n "$(find "$OUT" -newer "$i" 2>/dev/null)" ] &&
+ { [ -z "$CLICK" ] || [ -n "$(find "$OUT" -newer "$KCONFIG_CONFIG" 2>/dev/null)" ]; } &&
continue
do_loudly $BUILD -c $i -o $OUT &
diff --git a/scripts/mcm-buildall.sh b/scripts/mcm-buildall.sh
index cac41372..839dda44 100755
--- a/scripts/mcm-buildall.sh
+++ b/scripts/mcm-buildall.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Script to build all cross and native compilers supported by musl-libc.
# This isn't directly used by toybox, but is useful for testing.
@@ -22,7 +22,7 @@ BOOTSTRAP=i686-linux-musl
[ -z "$OUTPUT" ] && OUTPUT="$PWD/ccc"
-if [ "$1" == clean ]
+if [ "$1" = clean ]
then
rm -rf "$OUTPUT" host-* *.log
make clean
@@ -38,7 +38,7 @@ make_toolchain()
OUTPUT="$PWD/host-$TARGET"
EXTRASUB=y
else
- if [ "$TYPE" == static ]
+ if [ "$TYPE" = static ]
then
HOST=$BOOTSTRAP
[ "$TARGET" = "$HOST" ] && LP="$PWD/host-$HOST/bin:$LP"
@@ -53,7 +53,9 @@ make_toolchain()
echo "no $TARGET-cc in $LP" && return
fi
COMMON_CONFIG="CC=\"$HOST-gcc -static --static\" CXX=\"$HOST-g++ -static --static\""
- export -n HOST
+ _HOST="$HOST"
+ unset HOST
+ HOST="$_HOST"
OUTPUT="$OUTPUT/${RENAME:-$TARGET}-$TYPE"
fi
@@ -66,7 +68,7 @@ make_toolchain()
# Change title bar to say what we're currently building
echo === building $TARGET-$TYPE
- echo -en "\033]2;$TARGET-$TYPE\007"
+ printf '\033]2;%s-%s\007' "$TARGET" "$TYPE"
rm -rf build/"$TARGET" "$OUTPUT" &&
[ -z "$CPUS" ] && CPUS=$(($(nproc)+1))
@@ -76,10 +78,10 @@ make_toolchain()
COMMON_CONFIG="CFLAGS=\"$CFLAGS -g0 -Os\" CXXFLAGS=\"$CXXFLAGS -g0 -Os\" LDFLAGS=\"$LDFLAGS -s\" $COMMON_CONFIG" \
install -j$CPUS || exit 1
set +x
- echo -e '#ifndef __MUSL__\n#define __MUSL__ 1\n#endif' \
+ printf '#ifndef __MUSL__\n#define __MUSL__ 1\n#endif\n' \
>> "$OUTPUT/${EXTRASUB:+$TARGET/}include/features.h"
- if [ ! -z "$RENAME" ] && [ "$TYPE" == cross ]
+ if [ ! -z "$RENAME" ] && [ "$TYPE" = cross ]
then
CONTEXT="output/$RENAME-cross/bin"
for i in "$CONTEXT/$TARGET-"*
@@ -93,7 +95,7 @@ make_toolchain()
# $BOOTSTRAP arch
[ -z "$TYPE" ] && make clean
- if [ "$TYPE" == native ]
+ if [ "$TYPE" = native ]
then
# gcc looks in "../usr/include" but not "/bin/../include" (relative to the
# executable). That means /usr/bin/gcc looks in /usr/usr/include, so that's
@@ -108,14 +110,14 @@ make_toolchain()
# Expand compressed target into binutils/gcc "tuple" and call make_toolchain
make_tuple()
{
- PART1=${1/:*/}
- PART3=${1/*:/}
- PART2=${1:$((${#PART1}+1)):$((${#1}-${#PART3}-${#PART1}-2))}
+ PART1=${1%%:*}
+ PART3=${1##*:}
+ PART2=${1#${PART1}:} PART2=${PART2%:${PART3}}
# Do we need to rename this toolchain after building it?
- RENAME=${PART1/*@/}
- [ "$RENAME" == "$PART1" ] && RENAME=
- PART1=${PART1/@*/}
+ RENAME=${PART1##*@}
+ [ "$RENAME" = "$PART1" ] && RENAME=
+ PART1=${PART1%%@*}
TARGET=${PART1}-linux-musl${PART2}
[ -z "$NOCLEAN" ] && rm -rf build
diff --git a/scripts/portability.sh b/scripts/portability.sh
index 618022c7..dee5dc3f 100644
--- a/scripts/portability.sh
+++ b/scripts/portability.sh
@@ -1,6 +1,6 @@
# sourced to find alternate names for things
-source configure
+. ./configure
if [ -z "$(command -v "${CROSS_COMPILE}${CC}")" ]
then
diff --git a/scripts/record-commands b/scripts/record-commands
index 8410966b..f49bcff9 100755
--- a/scripts/record-commands
+++ b/scripts/record-commands
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Set up command recording wrapper
diff --git a/scripts/single.sh b/scripts/single.sh
index c40c6bcf..473bbdd4 100755
--- a/scripts/single.sh
+++ b/scripts/single.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
# Build a standalone toybox command
@@ -9,7 +9,7 @@ then
fi
# Add trailing / to PREFIX when it's set but hasn't got one
-[ "$PREFIX" == "${PREFIX%/}" ] && PREFIX="${PREFIX:+$PREFIX/}"
+[ "$PREFIX" = "${PREFIX%/}" ] && PREFIX="${PREFIX:+$PREFIX/}"
# Harvest TOYBOX_* symbols from .config
if [ ! -e .config ]
@@ -24,7 +24,7 @@ touch -c .config
export KCONFIG_CONFIG=.singleconfig
for i in "$@"
do
- echo -n "$i:"
+ printf '%s:' "$i"
TOYFILE="$(egrep -l "TOY[(]($i)[ ,]" toys/*/*.c)"
if [ -z "$TOYFILE" ]
@@ -37,7 +37,7 @@ do
DEPENDS=
MPDEL=
- if [ "$i" == sh ]
+ if [ "$i" = sh ]
then
DEPENDS="$(sed -n 's/USE_\([^(]*\)(NEWTOY([^,]*,.*TOYFLAG_MAYFORK.*/\1/p' toys/*/*.c)"
else