From b3d0cba33b0b7cdd58fa3ab233e7298b5403ad9d Mon Sep 17 00:00:00 2001 From: Tobia Caneschi Date: Tue, 22 Jan 2013 14:23:43 +0100 Subject: [PATCH 1/2] Fix for line:13 integer expression expected Patch for line 13. Tested from mac os, centos, redhat Added some facility and feedback --- ext/session/mod_files.sh | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/ext/session/mod_files.sh b/ext/session/mod_files.sh index 1d2672847c6e8..ef37ee702ece0 100644 --- a/ext/session/mod_files.sh +++ b/ext/session/mod_files.sh @@ -9,10 +9,26 @@ if test "$2" = "0"; then exit 0 fi +if test -z "$3"; then + param3=0 + + echo "Are you sure to create sessions tree dirs +in $1 root path with $2 depth? (Y|N)" + read input + if test "$input" != "Y"; then + echo "\nexit without process" + exit 0 + fi + echo "\nProcessing..." +else + param3=$3 +fi + + hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f" -if test "$3" -a "$3" -ge "5"; then +if test "$param3" -a "$param3" -ge "5"; then hash_chars="$hash_chars g h i j k l m n o p q r s t u v" - if test "$3" -eq "6"; then + if test "$param3" -eq "6"; then hash_chars="$hash_chars w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z - ," fi fi @@ -20,5 +36,7 @@ fi for i in $hash_chars; do newpath="$1/$i" mkdir $newpath || exit 1 - sh $0 $newpath `expr $2 - 1` $3 + sh $0 $newpath `expr $2 - 1` $param3 done + +echo "\nDone..." From 3cfecef3d0eaf5783e07046a592a02938917631b Mon Sep 17 00:00:00 2001 From: Tobia Caneschi Date: Thu, 31 Jan 2013 10:20:47 +0100 Subject: [PATCH 2/2] Fixed execution for non interactive shell Added check for interactive terminal. If the terminal is interactive then prompt is shown. --- ext/session/mod_files.sh | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) mode change 100644 => 100755 ext/session/mod_files.sh diff --git a/ext/session/mod_files.sh b/ext/session/mod_files.sh old mode 100644 new mode 100755 index ef37ee702ece0..1f5ae2a49ccd6 --- a/ext/session/mod_files.sh +++ b/ext/session/mod_files.sh @@ -1,5 +1,4 @@ -#! /bin/sh - +#!/bin/sh if test "$2" = ""; then echo "usage: $0 basedir depth" exit 1 @@ -12,19 +11,21 @@ fi if test -z "$3"; then param3=0 - echo "Are you sure to create sessions tree dirs + #Test of interactive shell terminl + if tty -s; then + echo "Are you sure to create sessions tree dirs in $1 root path with $2 depth? (Y|N)" - read input - if test "$input" != "Y"; then - echo "\nexit without process" - exit 0 + read input + if test "$input" != "Y"; then + echo "Exit without process" + exit 0 + fi fi - echo "\nProcessing..." + echo "$0: Processing $1 with $2 depth...." else param3=$3 fi - hash_chars="0 1 2 3 4 5 6 7 8 9 a b c d e f" if test "$param3" -a "$param3" -ge "5"; then hash_chars="$hash_chars g h i j k l m n o p q r s t u v" @@ -35,8 +36,10 @@ fi for i in $hash_chars; do newpath="$1/$i" - mkdir $newpath || exit 1 + mkdir -p $newpath || exit 1 sh $0 $newpath `expr $2 - 1` $param3 done -echo "\nDone..." +if test -z "$3"; then + echo "$0: Done" +fi