Skip to content

Commit cc5549c

Browse files
committed
scripts: use 4 space indentation
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.
1 parent 408c9a0 commit cc5549c

File tree

88 files changed

+806
-881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+806
-881
lines changed

.dir-locals.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
(nxml-mode . ((nxml-child-indent . 2)
2121
(fill-column . 109)))
2222
(meson-mode . ((meson-indent-basic . 8)))
23-
(sh-mode . ((sh-basic-offset . 8)
24-
(sh-indentation . 8)))
23+
(sh-mode . ((sh-basic-offset . 4)
24+
(sh-indentation . 4)))
2525
(awk-mode . ((c-basic-offset . 8)))
2626
(nil . ((indent-tabs-mode . nil)
2727
(tab-width . 8)

.editorconfig

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ charset = utf-8
1919
indent_style = space
2020
indent_size = 8
2121

22+
[*.sh]
23+
indent_style = space
24+
indent_size = 4
25+
2226
[meson.build]
2327
indent_style = space
2428
indent_size = 8

.vimrc

+1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ set expandtab
1717
set makeprg=GCC_COLORS=\ make
1818
set tw=79
1919
au BufRead,BufNewFile *.xml set tw=109 shiftwidth=2 smarttab
20+
au FileType sh set tw=80 shiftwidth=4 smarttab
2021
au FileType c set tw=109

coccinelle/run-coccinelle.sh

+13-13
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@ files="$(git ls-files ':/*.[ch]')"
55
args=
66

77
case "$1" in
8-
-i)
9-
args="$args --in-place"
10-
shift
11-
;;
8+
-i)
9+
args="$args --in-place"
10+
shift
11+
;;
1212
esac
1313

1414
if ! parallel -h >/dev/null; then
15-
echo 'Please install GNU parallel (package "parallel")'
16-
exit 1
15+
echo 'Please install GNU parallel (package "parallel")'
16+
exit 1
1717
fi
1818

1919
for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do
20-
echo "--x-- Processing $SCRIPT --x--"
21-
TMPFILE=`mktemp`
22-
echo "+ spatch --sp-file $SCRIPT $args ..."
23-
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
24-
spatch --sp-file $SCRIPT $args ::: $files \
25-
2>"$TMPFILE" || cat "$TMPFILE"
26-
echo -e "--x-- Processed $SCRIPT --x--\n"
20+
echo "--x-- Processing $SCRIPT --x--"
21+
TMPFILE=`mktemp`
22+
echo "+ spatch --sp-file $SCRIPT $args ..."
23+
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
24+
spatch --sp-file $SCRIPT $args ::: $files \
25+
2>"$TMPFILE" || cat "$TMPFILE"
26+
echo -e "--x-- Processed $SCRIPT --x--\n"
2727
done

man/50-xdg-data-dirs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}"
55

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

1111
# write our output

semaphoreci/gcc-compilation.sh

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -ex
43

54
# keep this in sync with setup.sh
@@ -40,4 +39,9 @@ dpkg-buildpackage -S -I -I$(basename "$SEMAPHORE_CACHE_DIR") -d -us -uc -nc
4039
# now build the package and run the tests
4140
rm -rf "$ARTIFACTS_DIR"
4241
# autopkgtest exits with 2 for "some tests skipped", accept that
43-
$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade --env DEB_BUILD_OPTIONS=noudeb --env TEST_UPSTREAM=1 ../systemd_*.dsc -o "$ARTIFACTS_DIR" -- lxc -s $CONTAINER || [ $? -eq 2 ]
42+
$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade \
43+
--env DEB_BUILD_OPTIONS=noudeb \
44+
--env TEST_UPSTREAM=1 ../systemd_*.dsc \
45+
-o "$ARTIFACTS_DIR" \
46+
-- lxc -s $CONTAINER \
47+
|| [ $? -eq 2 ]

semaphoreci/setup.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -ex
43

54
# default to Debian testing

src/basic/generate-af-list.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
set -eu
33

44
$1 -E -dM -include sys/socket.h -include "$2" -include "$3" - </dev/null | \
5-
grep -Ev 'AF_UNSPEC|AF_MAX' | \
6-
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'
5+
grep -Ev 'AF_UNSPEC|AF_MAX' | \
6+
awk '/^#define[ \t]+AF_[^ \t]+[ \t]+[AP]F_[^ \t]/ { print $2; }'

src/basic/generate-arphrd-list.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
set -eu
33

44
$1 -dM -include linux/if_arp.h -include "$2" - </dev/null | \
5-
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
6-
sed -e 's/ARPHRD_//'
5+
awk '/^#define[ \t]+ARPHRD_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
6+
sed -e 's/ARPHRD_//'

src/basic/generate-cap-list.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
set -eu
33

44
$1 -dM -include linux/capability.h -include "$2" -include "$3" - </dev/null | \
5-
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
6-
grep -v CAP_LAST_CAP
5+
awk '/^#define[ \t]+CAP_[A-Z_]+[ \t]+/ { print $2; }' | \
6+
grep -v CAP_LAST_CAP

src/basic/generate-errno-list.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
set -eu
33

44
$1 -dM -include errno.h - </dev/null | \
5-
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'
5+
awk '/^#define[ \t]+E[^ _]+[ \t]+/ { print $2; }'

src/boot/efi/no-undefined-symbols.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
set -eu
33

44
if nm -D -u "$1" | grep ' U '; then
5-
echo "Undefined symbols detected!"
6-
exit 1
5+
echo "Undefined symbols detected!"
6+
exit 1
77
fi

src/journal/generate-audit_type-list.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ shift
66

77
includes=""
88
for i in "$@"; do
9-
includes="$includes -include $i"
9+
includes="$includes -include $i"
1010
done
1111

1212
$cpp -dM $includes - </dev/null | \
13-
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
14-
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
15-
sort -k2
13+
grep -vE 'AUDIT_.*(FIRST|LAST)_' | \
14+
sed -r -n 's/^#define\s+AUDIT_(\w+)\s+([0-9]{4})\s*$$/\1\t\2/p' | \
15+
sort -k2

src/shared/generate-ip-protocol-list.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
set -eu
33

44
$1 -dM -include netinet/in.h - </dev/null | \
5-
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
6-
sed -e 's/IPPROTO_//'
5+
awk '/^#define[ \t]+IPPROTO_[^ \t]+[ \t]+[^ \t]/ { print $2; }' | \
6+
sed -e 's/IPPROTO_//'
+10-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
#!/bin/sh
22
set -eu
3-
awk ' BEGIN {
4-
print "%{\n\
3+
4+
awk '
5+
BEGIN {
6+
print "%{\n\
57
#if __GNUC__ >= 7\n\
68
_Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\
79
#endif\n\
810
%}"
9-
print "struct key_name { const char* name; unsigned short id; };"
10-
print "%null-strings"
11-
print "%%"
12-
}
11+
print "struct key_name { const char* name; unsigned short id; };"
12+
print "%null-strings"
13+
print "%%"
14+
}
1315
14-
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
15-
{ print tolower($1) ", " $1 }
16+
/^KEY_/ { print tolower(substr($1 ,5)) ", " $1 }
17+
{ print tolower($1) ", " $1 }
1618
' < "$1"

src/udev/generate-keyboard-keys-list.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
set -eu
33

44
$1 -dM -include linux/input.h - </dev/null | awk '
5-
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
6-
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
5+
/\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next }
6+
/^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 }
77
'

test/TEST-01-BASIC/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="Basic systemd setup"
64
RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes}

test/TEST-02-CRYPTSETUP/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="cryptsetup systemd setup"
64
TEST_NO_NSPAWN=1

test/TEST-03-JOBS/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="Job-related tests"
64
TEST_NO_QEMU=1

test/TEST-04-JOURNAL/test-journal.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -x
43
set -e
54
set -o pipefail

test/TEST-04-JOURNAL/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="Journal-related tests"
64

test/TEST-05-RLIMITS/test-rlimits.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -x
43
set -e
54
set -o pipefail

test/TEST-05-RLIMITS/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="Resource limits-related tests"
64

test/TEST-06-SELINUX/test-selinux-checks.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -x
43
set -e
54
set -o pipefail

test/TEST-06-SELINUX/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="SELinux tests"
64
TEST_NO_NSPAWN=1

test/TEST-07-ISSUE-1981/test-segfault.sh

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
2-
32
set -x
43
set -e
54

test/TEST-07-ISSUE-1981/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
64
TEST_NO_QEMU=1

test/TEST-08-ISSUE-2730/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
64
TEST_NO_NSPAWN=1

test/TEST-09-ISSUE-2691/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
64
TEST_NO_NSPAWN=1

test/TEST-10-ISSUE-2467/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467"
64

test/TEST-11-ISSUE-3166/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166"
64
TEST_NO_NSPAWN=1

test/TEST-12-ISSUE-3171/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171"
64
TEST_NO_QEMU=1

test/TEST-13-NSPAWN-SMOKE/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="systemd-nspawn smoke test"
64
TEST_NO_NSPAWN=1

test/TEST-14-MACHINE-ID/test.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#!/bin/bash
2-
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3-
# ex: ts=8 sw=4 sts=4 et filetype=sh
42
set -e
53
TEST_DESCRIPTION="/etc/machine-id testing"
64
TEST_NO_NSPAWN=1

0 commit comments

Comments
 (0)