Skip to content

Commit

Permalink
scripts: use 4 space indentation
Browse files Browse the repository at this point in the history
We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed.
4 sp was the most common, in particular the majority of scripts under test/
used that. Let's standarize on 4 sp, because many commandlines are long and
there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp
also seems to be the default indentation, so this will make it less likely
that people will mess up if they don't load the editor config. (I think people
often use vi, and vi has no support to load project-wide configuration
automatically. We distribute a .vimrc file, but it is not loaded by default,
and even the instructions in it seem to discourage its use for security
reasons.)

Also remove the few vim config lines that were left. We should either have them
on all files, or none.

Also remove some strange stuff like '#!/bin/env bash', yikes.
  • Loading branch information
keszybz committed Apr 12, 2019
1 parent 408c9a0 commit cc5549c
Show file tree
Hide file tree
Showing 88 changed files with 806 additions and 881 deletions.
4 changes: 2 additions & 2 deletions .dir-locals.el
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
(nxml-mode . ((nxml-child-indent . 2)
(fill-column . 109)))
(meson-mode . ((meson-indent-basic . 8)))
(sh-mode . ((sh-basic-offset . 8)
(sh-indentation . 8)))
(sh-mode . ((sh-basic-offset . 4)
(sh-indentation . 4)))
(awk-mode . ((c-basic-offset . 8)))
(nil . ((indent-tabs-mode . nil)
(tab-width . 8)
Expand Down
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ charset = utf-8
indent_style = space
indent_size = 8

[*.sh]
indent_style = space
indent_size = 4

[meson.build]
indent_style = space
indent_size = 8
1 change: 1 addition & 0 deletions .vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ set expandtab
set makeprg=GCC_COLORS=\ make
set tw=79
au BufRead,BufNewFile *.xml set tw=109 shiftwidth=2 smarttab
au FileType sh set tw=80 shiftwidth=4 smarttab
au FileType c set tw=109
26 changes: 13 additions & 13 deletions coccinelle/run-coccinelle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ files="$(git ls-files ':/*.[ch]')"
args=

case "$1" in
-i)
args="$args --in-place"
shift
;;
-i)
args="$args --in-place"
shift
;;
esac

if ! parallel -h >/dev/null; then
echo 'Please install GNU parallel (package "parallel")'
exit 1
echo 'Please install GNU parallel (package "parallel")'
exit 1
fi

for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do
echo "--x-- Processing $SCRIPT --x--"
TMPFILE=`mktemp`
echo "+ spatch --sp-file $SCRIPT $args ..."
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
spatch --sp-file $SCRIPT $args ::: $files \
2>"$TMPFILE" || cat "$TMPFILE"
echo -e "--x-- Processed $SCRIPT --x--\n"
echo "--x-- Processing $SCRIPT --x--"
TMPFILE=`mktemp`
echo "+ spatch --sp-file $SCRIPT $args ..."
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
spatch --sp-file $SCRIPT $args ::: $files \
2>"$TMPFILE" || cat "$TMPFILE"
echo -e "--x-- Processed $SCRIPT --x--\n"
done
2 changes: 1 addition & 1 deletion man/50-xdg-data-dirs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}"

# add a directory if it exists
if [[ -d /opt/foo/share ]]; then
XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS}
XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS}
fi

# write our output
Expand Down
8 changes: 6 additions & 2 deletions semaphoreci/gcc-compilation.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -ex

# keep this in sync with setup.sh
Expand Down Expand Up @@ -40,4 +39,9 @@ dpkg-buildpackage -S -I -I$(basename "$SEMAPHORE_CACHE_DIR") -d -us -uc -nc
# now build the package and run the tests
rm -rf "$ARTIFACTS_DIR"
# autopkgtest exits with 2 for "some tests skipped", accept that
$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade --env DEB_BUILD_OPTIONS=noudeb --env TEST_UPSTREAM=1 ../systemd_*.dsc -o "$ARTIFACTS_DIR" -- lxc -s $CONTAINER || [ $? -eq 2 ]
$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade \
--env DEB_BUILD_OPTIONS=noudeb \
--env TEST_UPSTREAM=1 ../systemd_*.dsc \
-o "$ARTIFACTS_DIR" \
-- lxc -s $CONTAINER \
|| [ $? -eq 2 ]
1 change: 0 additions & 1 deletion semaphoreci/setup.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -ex

# default to Debian testing
Expand Down
4 changes: 2 additions & 2 deletions src/basic/generate-af-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
set -eu

$1 -E -dM -include sys/socket.h -include "$2" -include "$3" - </dev/null | \
grep -Ev 'AF_UNSPEC|AF_MAX' | \
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'
grep -Ev 'AF_UNSPEC|AF_MAX' | \
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'
4 changes: 2 additions & 2 deletions src/basic/generate-arphrd-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
set -eu

$1 -dM -include linux/if_arp.h -include "$2" - </dev/null | \
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/ARPHRD_//'
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/ARPHRD_//'
4 changes: 2 additions & 2 deletions src/basic/generate-cap-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
set -eu

$1 -dM -include linux/capability.h -include "$2" -include "$3" - </dev/null | \
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
grep -v CAP_LAST_CAP
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
grep -v CAP_LAST_CAP
2 changes: 1 addition & 1 deletion src/basic/generate-errno-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
set -eu

$1 -dM -include errno.h - </dev/null | \
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
4 changes: 2 additions & 2 deletions src/boot/efi/no-undefined-symbols.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -eu

if nm -D -u "$1" | grep ' U '; then
echo "Undefined symbols detected!"
exit 1
echo "Undefined symbols detected!"
exit 1
fi
8 changes: 4 additions & 4 deletions src/journal/generate-audit_type-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ shift

includes=""
for i in "$@"; do
includes="$includes -include $i"
includes="$includes -include $i"
done

$cpp -dM $includes - </dev/null | \
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
sort -k2
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
sort -k2
4 changes: 2 additions & 2 deletions src/shared/generate-ip-protocol-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
set -eu

$1 -dM -include netinet/in.h - </dev/null | \
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/IPPROTO_//'
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
sed -e 's/IPPROTO_//'
18 changes: 10 additions & 8 deletions src/udev/generate-keyboard-keys-gperf.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/bin/sh
set -eu
awk ' BEGIN {
print "%{\n\

awk '
BEGIN {
print "%{\n\
#if __GNUC__ >= 7\n\
_Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\
#endif\n\
%}"
print "struct key_name { const char* name; unsigned short id; };"
print "%null-strings"
print "%%"
}
print "struct key_name { const char* name; unsigned short id; };"
print "%null-strings"
print "%%"
}
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
{ print tolower($1) ", " $1 }
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
{ print tolower($1) ", " $1 }
' < "$1"
4 changes: 2 additions & 2 deletions src/udev/generate-keyboard-keys-list.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
set -eu

$1 -dM -include linux/input.h - </dev/null | awk '
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
'
2 changes: 0 additions & 2 deletions test/TEST-01-BASIC/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="Basic systemd setup"
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-02-CRYPTSETUP/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="cryptsetup systemd setup"
TEST_NO_NSPAWN=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-03-JOBS/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="Job-related tests"
TEST_NO_QEMU=1
Expand Down
1 change: 0 additions & 1 deletion test/TEST-04-JOURNAL/test-journal.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -x
set -e
set -o pipefail
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-04-JOURNAL/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="Journal-related tests"

Expand Down
1 change: 0 additions & 1 deletion test/TEST-05-RLIMITS/test-rlimits.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -x
set -e
set -o pipefail
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-05-RLIMITS/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="Resource limits-related tests"

Expand Down
1 change: 0 additions & 1 deletion test/TEST-06-SELINUX/test-selinux-checks.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -x
set -e
set -o pipefail
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-06-SELINUX/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="SELinux tests"
TEST_NO_NSPAWN=1
Expand Down
1 change: 0 additions & 1 deletion test/TEST-07-ISSUE-1981/test-segfault.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

set -x
set -e

Expand Down
2 changes: 0 additions & 2 deletions test/TEST-07-ISSUE-1981/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
TEST_NO_QEMU=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-08-ISSUE-2730/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
TEST_NO_NSPAWN=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-09-ISSUE-2691/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
TEST_NO_NSPAWN=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-10-ISSUE-2467/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"

Expand Down
2 changes: 0 additions & 2 deletions test/TEST-11-ISSUE-3166/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
TEST_NO_NSPAWN=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-12-ISSUE-3171/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
TEST_NO_QEMU=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-13-NSPAWN-SMOKE/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="systemd-nspawn smoke test"
TEST_NO_NSPAWN=1
Expand Down
2 changes: 0 additions & 2 deletions test/TEST-14-MACHINE-ID/test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="/etc/machine-id testing"
TEST_NO_NSPAWN=1
Expand Down
Loading

0 comments on commit cc5549c

Please sign in to comment.