Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc9fb51

Browse files
committed
Moving parameter validation up to let users run ut_run from /
1 parent 3c51471 commit dc9fb51

3 files changed

Lines changed: 25 additions & 30 deletions

File tree

client_source/sqlplus/file_list

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
#!/bin/bash
22
set -e
33

4-
clientPath=${1%/}
5-
projectPath=${2%/}
6-
scanPath=$3
7-
outFileName=$4
8-
sqlParamName=$5
9-
10-
# All parameters are required.
4+
# All parameters are required. This way, users can't pass empty string as parameter.
115
invalidArgs=0
12-
[ -z "$clientPath" ] && invalidArgs=1
13-
[ -z "$projectPath" ] && invalidArgs=1
14-
[ -z "$scanPath" ] && invalidArgs=1
15-
[ -z "$outFileName" ] && invalidArgs=1
16-
[ -z "$sqlParamName" ] && invalidArgs=1
6+
[ -z "$1" ] && invalidArgs=1
7+
[ -z "$2" ] && invalidArgs=1
8+
[ -z "$3" ] && invalidArgs=1
9+
[ -z "$4" ] && invalidArgs=1
10+
[ -z "$5" ] && invalidArgs=1
1711

1812
if [ $invalidArgs -eq 1 ]; then
1913
echo Usage: ut_run.sh "client_path" "project_path" "scan_path" "out_file_name" "sql_param_name"
2014
exit 1
2115
fi
2216

17+
clientPath=${1%/}
18+
projectPath=${2%/}
19+
scanPath=$3
20+
outFileName=$4
21+
sqlParamName=$5
22+
2323
fullOutPath="$clientPath/$outFileName"
2424
fullScanPath="$projectPath/$scanPath"
2525

client_source/sqlplus/file_list.bat

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
@echo off
22
setlocal EnableDelayedExpansion
33

4-
set clientPath=%~1
5-
set projectPath=%~2
6-
set scanPath=%~3
7-
set outFileName=%~4
8-
set sqlParamName=%~5
9-
10-
REM All parameters are required.
4+
REM All parameters are required. This way, users can't pass empty string as parameter.
115
set invalidArgs=0
12-
if "%clientPath%" == "" set invalidArgs=1
13-
if "%projectPath%" == "" set invalidArgs=1
14-
if "%scanPath%" == "" set invalidArgs=1
15-
if "%outFileName%" == "" set invalidArgs=1
16-
if "%sqlParamName%" == "" set invalidArgs=1
6+
if "%1" == "" set invalidArgs=1
7+
if "%2" == "" set invalidArgs=1
8+
if "%3" == "" set invalidArgs=1
9+
if "%4" == "" set invalidArgs=1
10+
if "%5" == "" set invalidArgs=1
1711

1812
if %invalidArgs% == 1 (
1913
echo Usage: ut_run.bat "client_path" "project_path" "scan_path" "out_file_name" "sql_param_name"
2014
exit /b 1
2115
)
2216

17+
set clientPath=%~1
18+
set projectPath=%~2
19+
set scanPath=%~3
20+
set outFileName=%~4
21+
set sqlParamName=%~5
22+
2323
REM Remove trailing slashes.
2424
if %clientPath:~-1%==\ set clientPath=%clientPath:~0,-1%
2525
if %projectPath:~-1%==\ set projectPath=%projectPath:~0,-1%

client_source/sqlplus/ut_run

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
11
#!/bin/bash
22
set -e
33

4-
# Not forget to convert line endings to Unix.
5-
# http://linuxcommand.org/man_pages/dos2unix1.html
6-
# sed -i 's/\r//' ut_run
7-
# sed -i 's/\r//' file_list
8-
94
clientDir="$(dirname "$(readlink -f "$0")")"
105
projectDir="$(pwd)"
116

12-
if [ "$clientDir" != "${clientDir% *}" ]; then
7+
if [[ "$clientDir" != "${clientDir% *}" ]]; then
138
echo "Error: ut_run script path cannot have spaces."
149
exit 1
1510
fi

0 commit comments

Comments
 (0)