From: Tom de Vries Date: Tue, 26 Nov 2024 08:49:29 +0000 (+0100) Subject: [gdb/syscalls] Improve update-linux-from-src.sh X-Git-Tag: gdb-16-branchpoint~298 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=eb522d6d1325c6604716e7f3fd70d351400ee541;p=thirdparty%2Fbinutils-gdb.git [gdb/syscalls] Improve update-linux-from-src.sh Some improvements in gdb/syscalls/update-linux-from-src.sh: - use bash instead of sh - use local to distinguish between local and global vars (which brings to light that pre uses the global rather than the local start_date) - factor out main and parse_args - factor out regen - iterate over *.xml.in instead of *.in Tested on aarch64-linux. Verified with shellcheck. --- diff --git a/gdb/syscalls/update-linux-from-src.sh b/gdb/syscalls/update-linux-from-src.sh index 21c921af126..b6985bae88c 100755 --- a/gdb/syscalls/update-linux-from-src.sh +++ b/gdb/syscalls/update-linux-from-src.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright (C) 2022-2024 Free Software Foundation, Inc. # @@ -20,23 +20,30 @@ # Used to generate .xml.in files, like so: # $ ./update-linux-from-src.sh ~/linux-stable.git -if [ $# -lt 1 ]; then - echo "dir argument needed" - exit 1 -fi - -d="$1" -shift - -if [ ! -d "$d" ]; then - echo "cannot find $d" - exit 1 -fi +parse_args () +{ + if [ $# -lt 1 ]; then + echo "dir argument needed" + exit 1 + fi + + d="$1" + shift + + if [ ! -d "$d" ]; then + echo "cannot find $d" + exit 1 + fi +} pre () { + local f f="$1" + local start_date + start_date="$2" + local year year=$(date +%Y) cat < "$f" +} + +main () +{ + # Set global d. + parse_args "$@" + + local f + for f in *.xml.in; do + regen "$f" + done +} -done +main "$@"