"if test ..." replaced by "if [ ... ]"

Fixed up the remnants of the early style mix
to correspond to the proposed doc/style.txt;
the rationale being that

	if [ ... ]; then
		...
		...
	fi

is the more readable construct among itself,

	if test ...; then
		...
		...
	fi

and

	[ ... ] && {
		...
		...
	}

due to the condition being more distinguishable
when bracketed and the body more apparent as the
one inside "if" and not any other block; the less
obvious difference is that the final construct of
the latter form is prone to the whole script exit
status being non-zero if the condition isn't met.
This commit is contained in:
Michael Shigorin 2011-12-21 12:14:03 +02:00
parent a8ccfb3d41
commit 180ed5359c
4 changed files with 8 additions and 8 deletions

View File

@ -108,7 +108,7 @@ $(FEATURES):
if [ -s "generate.mk" ]; then $(MAKE) -f generate.mk; fi; \
if type -t git >&/dev/null && \
pushd "$(BUILDDIR)/" >/dev/null; then \
if test -n "`git status -s`"; then \
if [ -n "`git status -s`" ]; then \
git add . && \
git commit -qam "$$feat feature generation complete"; \
fi; \

View File

@ -58,7 +58,7 @@ prep:
@mkdir -p $(DSTDIR)
debug:
@if test -n "$(DEBUG)"; then \
@if [ -n "$(DEBUG)" ]; then \
echo "** BOOTLOADER: $(BOOTLOADER)"; \
echo "** SYSLINUX_UI: $(SYSLINUX_UI)"; \
echo "** SYSLINUX_CFG: $(SYSLINUX_CFG)"; \

View File

@ -16,15 +16,15 @@ esac
# copy extra files, if any
SYSLINUX_FILES="$(cat .in/files.list)"
if test -n "${SYSLINUX_FILES% }"; then
if [ -n "${SYSLINUX_FILES% }" ]; then
cp -a $SYSLINUX_FILES .
fi
# prune module-specific config snippets; skip built-in one
SYSLINUX_MODULES="$(cat .in/modules.list)"
if test -n "$SYSLINUX_MODULES"; then
if [ -n "$SYSLINUX_MODULES" ]; then
for module in $SYSLINUX_MODULES; do
if test "$modules" == "prompt"; then continue; fi
if [ "$modules" == "prompt" ]; then continue; fi
cp -a $MODDIR/$module.c?? . || rm .in/[0-9][0-9]$module.cfg
done
fi
@ -33,7 +33,7 @@ fi
grep -hv '^#' .in/[0-9][0-9]*.cfg > "$BOOTLOADER.cfg"
# snippets are not going into the actual image
if test "$DEBUG" != 2; then rm -r .in/; fi
if [ "$DEBUG" != 2 ]; then rm -r .in/; fi
# NB: there will be final macro expansion based on actual image sizes
# (done by ../../scripts.d/10-propagator-ramdisk)

View File

@ -41,12 +41,12 @@ CHROOT_PACKAGES = $(STAGE1_PACKAGES) $(SYSTEM_PACKAGES)
# NB: we pass tested squashfs options for ../install2/Makefile
all: | debug prepare-workdir copy-tree run-scripts $(BUILD_PROPAGATOR) \
copy-$(BOOTLOADER) $(COPY_SQUASHCFG) pack-image $(GLOBAL_CLEAN_WORKDIR)
@if test -s $(OUTDIR)/squashcfg.mk; then \
@if [ -s $(OUTDIR)/squashcfg.mk ]; then \
cp $(OUTDIR)/squashcfg.mk $(GLOBAL_BUILDDIR)/; \
fi
debug:
@if test -n "$(GLOBAL_VERBOSE)"; then \
@if [ -n "$(GLOBAL_VERBOSE)" ]; then \
echo "** BRANDING: $(BRANDING)"; \
echo "** IMAGE_INIT_LIST: $(IMAGE_INIT_LIST)"; \
echo "** STAGE1_PACKAGES: $(STAGE1_PACKAGES)"; \