Mercurial > hg > dtl-dml-cliopatria
view cpack/dml/scripts/compression/bufs @ 7:3c7cc53984a6 no-matlab tip
removed rcutils as seem incompatible with this version
(no history/2 defined)
author | wolffd.mail@googlemail.com |
---|---|
date | Wed, 25 Jul 2018 15:51:48 +0000 |
parents | 718306e29690 |
children |
line wrap: on
line source
#!/bin/sh if [ $# -lt 3 ]; then echo 'bufs <n:int> <command> <arg1> <arg2> ...' echo echo 'Apply command to arguments but buffering the nth argument' echo 'of command (ie (n+1)th argument of strm) into a temporary file.' echo 'This means that the nth argument can safely be replaced with' echo 'a bash process redirection.' exit 1 fi set -o nounset set -e function str1 { cmd="$1" arg1="$2" tmp=`mktemp -t strXXX` # echo created $tmp 1>&2 trap "rm -f $tmp; exit" INT KILL EXIT shift 2 (cat "$arg1" > $tmp) && $cmd $tmp "$@" } function str { pos=$1 shift 1 if [ $pos -eq 1 ]; then str1 "$@" else cmd="$1 $2" shift 2 str $(($pos-1)) "$cmd" "$@" fi } str "$@"