diff --git a/5point/5point b/5point/5point index 1967195d8286cd313969f923531f937cb40e0090..d47e75e6efa59b3662a6ea7a8e7fe73cbedabe64 100644 --- a/5point/5point +++ b/5point/5point @@ -132,12 +132,12 @@ untag(){ for j in $(ls -1 $delfolder) do i="$delfolder/$j" - target=$(ls -l $i |cut -d ">" -f 2 ) - if test $target -ef $1; then + untarget=$(ls -l $i |cut -d ">" -f 2 ) + if test $untarget -ef $1; then file_date=$(echo "$j" | cut -d "_" -f 1) file_date=$(date --date="@$file_date") rm -f $i - echo $target "untagged from deletion at $file_date" + echo $untarget "untagged from deletion at $file_date" fi done else @@ -149,8 +149,14 @@ untag(){ # tag file for deletion tag(){ if [ $# == 2 ]; then - target="$PWD/$1" - datum=$(date +%s_%Y%m%d%H%M%S_%N -d "$2") + target=$PWD/$1 + #target=$1 + datum=$(date +%s_%Y%m%d%H%M%S_%N -d "$2") + if [ "$datum" == "" ]; then + echo "ERROR: $2 is not a valid date" + echo "typ '5point -h' for help" + exit 1 + fi answer=$(date -d "$2") deldate=$(date +%s) if [ -f $target ]; then @@ -162,7 +168,7 @@ tag(){ echo "ERROR: $target FILE does not exist" fi else - echo "ERROR: two arguments reyuired to tag file with deletion date" + echo "ERROR: two arguments required to tag file with deletion date" fi } @@ -198,11 +204,15 @@ fi # If yes list files and deletion time if [[ ( $1 == "--untag") || $1 == "-u" ]] then - if [[$# == 1]]; then + if [[ $# == 1 ]]; then echo "ERROR: specify FILE to untag" exit 1 else - untag $2 + array=( "$@" ) + array=( "${array[@]:1}" ) # Removes first element + for untargetfile in "${array[@]}"; do + untag $untargetfile + done exit 0 fi fi @@ -210,29 +220,21 @@ fi ######## Main program -if [ $# -gt 2 ]; then - echo "ERROR: too many argument, multiple file tagging not yet implemented" - echo "type '$0 -h' for help" - exit 1 -fi - - -if [ $# -ge 1 ]; then - if ! test -f $1; then - echo "ERROR: FILE $1 does not exist" - exit 1 - fi -fi - - if [ $# = 1 ]; then echo "ERROR: no deletion date specified for file $1" echo "type '$0 -h' for help" exit 1 fi -tag $1 $2 - +# work through files +if [ $# -ge 2 ]; then + deltime=${@: -1} + array=( "$@" ) + unset "array[${#array[@]}-1]" # Removes last element + for targetfile in "${array[@]}"; do + tag $targetfile $deltime + done +fi # ask whether zombies shall be deleted and do that interactively if check_for_zombies; then @@ -240,7 +242,11 @@ if check_for_zombies; then ask_to_delete_zombies fi exit 0 -#fi + + + + +