github.com/grafana/synthetic-monitoring-agent@v0.64.2/scripts/list-sh-scripts (about) 1 #!/bin/sh 2 3 type='sh' 4 5 while true ; do 6 [ "$#" -eq 0 ] && break 7 8 getopts 's:' opt 9 10 case $opt in 11 s) 12 type="$OPTARG" 13 shift 14 ;; 15 *) 16 echo "Usage: $0 -s<shell>" 17 exit 1 18 ;; 19 esac 20 done 21 22 case $type in 23 sh) 24 pat='^\s*#!\s*/bin/sh' 25 ;; 26 bash) 27 pat='^\s*#!\s*(/usr/bin/env bash|/bin/bash)' 28 ;; 29 *) 30 echo "Unknown shell: $type" 31 exit 1 32 ;; 33 esac 34 35 git ls-files -z | 36 xargs -r0 file --no-pad --mime-type | 37 grep ': text/x-shellscript' | 38 cut -d: -f1 | 39 while read -r script; do 40 grep -qE "${pat}" "$script" && echo "$script" 41 done