File: remove_trailing_whitespace.sh

package info (click to toggle)
simdjson 4.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,936 kB
  • sloc: cpp: 171,612; ansic: 19,122; sh: 1,126; python: 842; makefile: 47; ruby: 25; javascript: 13
file content (19 lines) | stat: -rwxr-xr-x 516 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#
# removes trailing whitespace from source files and other

set -eu

# go to the git root dir
cd "$(git rev-parse --show-toplevel)"

#make a list of all files (null separated, to handle whitespace)
git ls-tree -r HEAD --name-only -z >all_files.null.txt

for suffix in cpp cmake h hpp js md py rb sh ; do
   echo "removing trailing whitespace from files with suffix $suffix"
   cat all_files.null.txt | grep -z '\.'$suffix'$' |xargs -n1 --null sed -i 's/[ \t]*$//'
done
rm all_files.null.txt
echo "done!"