Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peter:/usr/bin # ls -l gcc*
- lrwxrwxrwx 1 root root 9 Oct 10 09:10 gcc -> gcc.wrap2
- -rwxr-xr-x 1 root root 345208 Oct 29 2011 gcc-4.6
- lrwxrwxrwx 1 root root 7 Jul 8 17:16 gcc.real -> gcc-4.6
- -rwxr-xr-x 1 root root 902 Oct 9 22:28 gcc.wrap
- -rwxr-xr-x 1 root root 11500 Oct 10 09:12 gcc.wrap2
- -rw-r--r-- 1 root root 539 Oct 10 09:12 gcc.wrap2.c
- -rwxr-xr-x 1 root root 2018 Oct 29 2011 gccmakedep
- peter:/usr/bin # cat gcc.wrap
- #!/bin/bash
- dir=$(dirname "$0")
- real="gcc.real"
- IFS=$'\n'
- args=()
- i=0
- removed=0
- for arg in "$@"; do
- echo "PM gcc.wrap: arg is \"$arg\""
- if echo "$arg " | grep "\-Werror" >/dev/null; then
- echo "PM gcc.wrap: found -Werror... removing it"
- arg=$(echo "$arg" | sed -r "s/-Werror//")
- echo "PM gcc.wrap: arg after removal: $arg"
- removed=1
- if [ "$arg" = "" -o "$arg" = " " ]; then
- echo "PM gcc.wrap: arg is now blank, so omitting"
- continue
- fi
- fi
- args[$i]="$arg"
- let i++
- done
- if [ "$removed" = "1" ]; then
- echo "PM gcc.wrap:command is: \"$dir\"/gcc.real ${args[@]} && exit 0 || exit 1"
- "$dir"/"$real" "${args[@]}" && exit 0 || exit 1
- else
- # for cases when nothing is changed, just run the thing normally (so buggy side effects are gone)
- "$dir"/"$real" "$@" && exit 0 || exit 1
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement