LINUX.ORG.RU

История изменений

Исправление Spoofing, (текущая версия) :

#!/bin/sh

main() {
  echo делаем бесполезную работу
}

die() {
  rm "$@/script.lock"
}

test -d "$@" || {
  echo "$@" is not a directory
  exit
}

test -a "$@/script.lock" && {
  echo $0 is already running in "$@" directory
  exit
}
> "$@/script.lock"

trap die INT

main "$@"

die "$@"

Исходная версия Spoofing, :

#!/bin/sh

main() {
  echo делаем бесполезную работу
}

die() {
  rm "$@/script.lock"
}

test -d "$@" || {
  echo "$@" is not a directory
  exit
}

test -a "$@/script.lock" && {
  echo $0 is already running in "$@" directory
  exit
}
> "$@/script.lock"

trap die INT

main "$@"

die