Files
servo/python/tidy/tests/shell_tidy.sh
Jonathan Schwender 9a4192a5e3 tidy: Improve check_shell substitution lint (#42099)
Probably we should use a proper linter like `shellcheck`, but in the
meantime make the lint slightly smarter, so that it doesn't complaint
about e.g. `$1`. This is especially a problem when adding scripts which
use `awk`, since our lint is quite stupid and doesn't understand `''`
strings.
This fixes linting, for a simple new script introduced in
https://github.com/servo/servo/pull/41775

Testing: ./mach test-tidy still passes.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-01-23 15:10:15 +00:00

21 lines
444 B
Bash

#!/bin/bash
#
# Tests tidy for shell scripts.
set -o nounset
# Talking about some `concept in backticks` # shouldn't trigger
echo "hello world"
some_var=`echo "command substitution"`
another_var="$some_var"
if [ -z "${some_var}" ]; then
echo "should have used [["
fi
[ -z "${another_var}" ]
# Using $@, $1 etc. shouldn't trigger.
echo "$@"
if [[ -n "$1" ]]; then
echo "parameter 1 is $1"
fi
echo "item1 item2 item3" | awk '{$1=$1;print}'