22 lines
422 B
Shell
Executable file
22 lines
422 B
Shell
Executable file
#!/bin/sh
|
|
set -e
|
|
|
|
lukko="${1:?vaaditaan lukon nimi}"
|
|
shift
|
|
|
|
case "$lukko" in
|
|
.|..|*/*)
|
|
printf '%s: virhe: lukon täytyy olla tiedostonimi: %s\n' "$(basename "$0")" "$lukko" >&2
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
hakemisto="$HOME/tmp/lukot/$lukko"
|
|
mkdir -p "$hakemisto"
|
|
|
|
lukkotiedosto="$hakemisto/$$"
|
|
trap 'exit' HUP INT QUIT TERM
|
|
trap 'rm -f "$lukkotiedosto"; rmdir "$hakemisto" 2>/dev/null || true' EXIT
|
|
touch "$lukkotiedosto"
|
|
|
|
"$@"
|