File: pipe2tmpfile

package info (click to toggle)
pwdsphinx 2.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 856 kB
  • sloc: python: 3,793; javascript: 1,001; sh: 238; makefile: 74
file content (26 lines) | stat: -rwxr-xr-x 402 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh -e

keyroot=/run/user/$(id -u)
keyfile=$(mktemp -p ${keyroot})

cleanup() {
   rm -f "${keyfile}"
}

cat >$keyfile
trap "cleanup" INT TERM QUIT EXIT

replace() {
for i do 
   arg="$i"
   if [ "x$arg" == "x@@keyfile@@" ]; then
      arg="$keyfile"
   fi
   printf %s\\n "$arg" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"
done
echo " "
}

newargs=$(replace "$@")
eval "set -- $newargs"
"${@}"