Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sed_inplace_arg = "-i"
- sed_inplace_arg_darwin = "-i ''"
- sed_extended_re_arg = "-r"
- sed_extended_re_arg_darwin = "-E"
- sed () {
- # Sed portability notes
- # - SuSv3
- # - Only -e, -f, and -n are standard options
- # - Linux
- # - -i argument is of the form -i[ext]
- # - extended regular expressions argument is -r
- # - Mac OSX
- # - -i argument is of the form -i [ext]
- # - extended regular expressions argument is -E
- #
- # Here we support a limited subset of the available sed capabilities,
- # ensuring that all those supported by this function can be utilized
- # regardless of the current platform.
- #
- # We accept -n, -e, -f, and -i with no backup extension. We support
- # extended regular expressions using the -r argument. Note that extended
- # regular expressions support may not be retained, depending upon the
- # capabilities of the other platforms we wish to support, and we may need
- # to reimplement -i internally in this script on some platforms.
- args=`getopt ner:f:i "$@"` || return 1
- set -- $args
- opts=""
- while [ $# -gt 0 ]; do
- case $1 in
- -i)
- opts="$opts ${sed_inplace_arg}"
- ;;
- -r)
- opts="$opts ${sed_extended_re_arg}"
- ;;
- --)
- shift
- break
- ;;
- *)
- opts="$opts \"$1\""
- ;;
- esac
- shift
- done
- eval command sed $opts "$@"
- }
Add Comment
Please, Sign In to add comment