Command not found error in Bash script












2















So I have written a bashscript.sh file to check if a directory project1_repo is empty after cloning a project.



I have written four different functions to authenticate it but all the time I get command not found error. I have checked multiple times if there is a syntax error but in vain. Could someone please help me out? Thanks.



EDIT: Previously due to a typo project1_install_dir was called colsim1_install_dir but the edited version is correct.



#!/bin/bash

#path to install project1
function project1_install_dir() {
while true;
do
read -p "Enter FULL folder path where you want to install project1:" fullpath
echo "you have enterd $fullpath. Please press 'y' to confirm and 'n' to enter again"
read -p "Continue? (Y/N): " confirm
if [[ $confirm =~ ^([yY][eE][sS]|[yY])$ ]]; then
break
else
continue
fi
done
}

#clone project1
function clone_project1_repo() {
git clone example git .
}

# four functions to Check whether cloning is successful
# function 1
function success_of_cloning_of_project1_repo3() {
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
echo "dir not empty"
else
echo "dir empty"
fi
}

# function 2
function success_of_cloning_of_project_repo2() {
DIR="$fullpath/project1/project1_repo"
if [ -n "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi
}

# function 3
function success_of_cloning_of_project_repo1() {
if [ -d $fullpath/project1/project1_repo ]; then
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
else
:
fi
}

# function 4
function success_of_cloning_of_project_repo() {
while true;
do
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
echo "cloning of project1_repo is successful"
break
else
echo "cloning of project1_repo is NOT successful."
continue
fi
done
}

#calling the functions
function main() {
project1_install_dir
success_of_cloning_of_project1_repo3
success_of_cloning_of_project1_repo2
success_of_cloning_of_project1_repo1
success_of_cloning_of_project1_repo
}

main


Terminal output:



jen@ex343:tdk/jen$ source bash_file_test.sh 
Enter FULL folder path where you want to install project1:/tdk/jen

you have enterd /tdk/jen. Please press 'y' to confirm and 'n' to enter again
Continue? (Y/N): y
You have chosen yes
-bash: success_of_cloning_of_project1_repo3: command not found
-bash: success_of_cloning_of_project1_repo2: command not found
-bash: success_of_cloning_of_project1_repo1: command not found
-bash: success_of_cloning_of_project1_repo: command not found









share|improve this question




















  • 1





    Your terminal output and the script are inconsistent. The main() function calls project1_install_dir but there's no such function anywhere to be found in the script. But from your output colsim1_install_dir seems to be called first. Is project1_install_dir another script installed somewhere ? As for the output -bash: success_of_cloning_of_colsim1_utilities_repo3: it seems like function name got mangled with other function name.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:35











  • Sorry. There was a typo..both should be project1_install_dir. I have edited. sorry again.

    – Jenny
    Mar 18 at 3:40











  • No problems. So far I don't see any issue related to the error itself. You have a few places where variable $fullpath should be quoted and read -r -p should be used instead of just read -p , but these shouldn't be the cause of the error.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:53











  • Was this script ever on windows or anything that could have potentially inserted newline endings specific to DOS ? Do you use a non-English keyboard that could have entered different types of space characters ? I know with Chinese inputs there is a wide space character, which is different from ASCII space. Try doing cat -A ./scriptname.sh , maybe it will show special characters besides just $ line ending

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:59











  • No, it has never been on Windows. Yes I have a German keyboard. But I don't think I've ever used any German characters. cat -A ./scriptname.sh didn't show any special characters than $ signs

    – Jenny
    Mar 18 at 4:04


















2















So I have written a bashscript.sh file to check if a directory project1_repo is empty after cloning a project.



I have written four different functions to authenticate it but all the time I get command not found error. I have checked multiple times if there is a syntax error but in vain. Could someone please help me out? Thanks.



EDIT: Previously due to a typo project1_install_dir was called colsim1_install_dir but the edited version is correct.



#!/bin/bash

#path to install project1
function project1_install_dir() {
while true;
do
read -p "Enter FULL folder path where you want to install project1:" fullpath
echo "you have enterd $fullpath. Please press 'y' to confirm and 'n' to enter again"
read -p "Continue? (Y/N): " confirm
if [[ $confirm =~ ^([yY][eE][sS]|[yY])$ ]]; then
break
else
continue
fi
done
}

#clone project1
function clone_project1_repo() {
git clone example git .
}

# four functions to Check whether cloning is successful
# function 1
function success_of_cloning_of_project1_repo3() {
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
echo "dir not empty"
else
echo "dir empty"
fi
}

# function 2
function success_of_cloning_of_project_repo2() {
DIR="$fullpath/project1/project1_repo"
if [ -n "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi
}

# function 3
function success_of_cloning_of_project_repo1() {
if [ -d $fullpath/project1/project1_repo ]; then
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
else
:
fi
}

# function 4
function success_of_cloning_of_project_repo() {
while true;
do
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
echo "cloning of project1_repo is successful"
break
else
echo "cloning of project1_repo is NOT successful."
continue
fi
done
}

#calling the functions
function main() {
project1_install_dir
success_of_cloning_of_project1_repo3
success_of_cloning_of_project1_repo2
success_of_cloning_of_project1_repo1
success_of_cloning_of_project1_repo
}

main


Terminal output:



jen@ex343:tdk/jen$ source bash_file_test.sh 
Enter FULL folder path where you want to install project1:/tdk/jen

you have enterd /tdk/jen. Please press 'y' to confirm and 'n' to enter again
Continue? (Y/N): y
You have chosen yes
-bash: success_of_cloning_of_project1_repo3: command not found
-bash: success_of_cloning_of_project1_repo2: command not found
-bash: success_of_cloning_of_project1_repo1: command not found
-bash: success_of_cloning_of_project1_repo: command not found









share|improve this question




















  • 1





    Your terminal output and the script are inconsistent. The main() function calls project1_install_dir but there's no such function anywhere to be found in the script. But from your output colsim1_install_dir seems to be called first. Is project1_install_dir another script installed somewhere ? As for the output -bash: success_of_cloning_of_colsim1_utilities_repo3: it seems like function name got mangled with other function name.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:35











  • Sorry. There was a typo..both should be project1_install_dir. I have edited. sorry again.

    – Jenny
    Mar 18 at 3:40











  • No problems. So far I don't see any issue related to the error itself. You have a few places where variable $fullpath should be quoted and read -r -p should be used instead of just read -p , but these shouldn't be the cause of the error.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:53











  • Was this script ever on windows or anything that could have potentially inserted newline endings specific to DOS ? Do you use a non-English keyboard that could have entered different types of space characters ? I know with Chinese inputs there is a wide space character, which is different from ASCII space. Try doing cat -A ./scriptname.sh , maybe it will show special characters besides just $ line ending

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:59











  • No, it has never been on Windows. Yes I have a German keyboard. But I don't think I've ever used any German characters. cat -A ./scriptname.sh didn't show any special characters than $ signs

    – Jenny
    Mar 18 at 4:04
















2












2








2








So I have written a bashscript.sh file to check if a directory project1_repo is empty after cloning a project.



I have written four different functions to authenticate it but all the time I get command not found error. I have checked multiple times if there is a syntax error but in vain. Could someone please help me out? Thanks.



EDIT: Previously due to a typo project1_install_dir was called colsim1_install_dir but the edited version is correct.



#!/bin/bash

#path to install project1
function project1_install_dir() {
while true;
do
read -p "Enter FULL folder path where you want to install project1:" fullpath
echo "you have enterd $fullpath. Please press 'y' to confirm and 'n' to enter again"
read -p "Continue? (Y/N): " confirm
if [[ $confirm =~ ^([yY][eE][sS]|[yY])$ ]]; then
break
else
continue
fi
done
}

#clone project1
function clone_project1_repo() {
git clone example git .
}

# four functions to Check whether cloning is successful
# function 1
function success_of_cloning_of_project1_repo3() {
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
echo "dir not empty"
else
echo "dir empty"
fi
}

# function 2
function success_of_cloning_of_project_repo2() {
DIR="$fullpath/project1/project1_repo"
if [ -n "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi
}

# function 3
function success_of_cloning_of_project_repo1() {
if [ -d $fullpath/project1/project1_repo ]; then
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
else
:
fi
}

# function 4
function success_of_cloning_of_project_repo() {
while true;
do
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
echo "cloning of project1_repo is successful"
break
else
echo "cloning of project1_repo is NOT successful."
continue
fi
done
}

#calling the functions
function main() {
project1_install_dir
success_of_cloning_of_project1_repo3
success_of_cloning_of_project1_repo2
success_of_cloning_of_project1_repo1
success_of_cloning_of_project1_repo
}

main


Terminal output:



jen@ex343:tdk/jen$ source bash_file_test.sh 
Enter FULL folder path where you want to install project1:/tdk/jen

you have enterd /tdk/jen. Please press 'y' to confirm and 'n' to enter again
Continue? (Y/N): y
You have chosen yes
-bash: success_of_cloning_of_project1_repo3: command not found
-bash: success_of_cloning_of_project1_repo2: command not found
-bash: success_of_cloning_of_project1_repo1: command not found
-bash: success_of_cloning_of_project1_repo: command not found









share|improve this question
















So I have written a bashscript.sh file to check if a directory project1_repo is empty after cloning a project.



I have written four different functions to authenticate it but all the time I get command not found error. I have checked multiple times if there is a syntax error but in vain. Could someone please help me out? Thanks.



EDIT: Previously due to a typo project1_install_dir was called colsim1_install_dir but the edited version is correct.



#!/bin/bash

#path to install project1
function project1_install_dir() {
while true;
do
read -p "Enter FULL folder path where you want to install project1:" fullpath
echo "you have enterd $fullpath. Please press 'y' to confirm and 'n' to enter again"
read -p "Continue? (Y/N): " confirm
if [[ $confirm =~ ^([yY][eE][sS]|[yY])$ ]]; then
break
else
continue
fi
done
}

#clone project1
function clone_project1_repo() {
git clone example git .
}

# four functions to Check whether cloning is successful
# function 1
function success_of_cloning_of_project1_repo3() {
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
echo "dir not empty"
else
echo "dir empty"
fi
}

# function 2
function success_of_cloning_of_project_repo2() {
DIR="$fullpath/project1/project1_repo"
if [ -n "$(ls -A $DIR)" ]; then
echo "Take action $DIR is not Empty"
else
echo "$DIR is Empty"
fi
}

# function 3
function success_of_cloning_of_project_repo1() {
if [ -d $fullpath/project1/project1_repo ]; then
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
else
:
fi
}

# function 4
function success_of_cloning_of_project_repo() {
while true;
do
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
echo "cloning of project1_repo is successful"
break
else
echo "cloning of project1_repo is NOT successful."
continue
fi
done
}

#calling the functions
function main() {
project1_install_dir
success_of_cloning_of_project1_repo3
success_of_cloning_of_project1_repo2
success_of_cloning_of_project1_repo1
success_of_cloning_of_project1_repo
}

main


Terminal output:



jen@ex343:tdk/jen$ source bash_file_test.sh 
Enter FULL folder path where you want to install project1:/tdk/jen

you have enterd /tdk/jen. Please press 'y' to confirm and 'n' to enter again
Continue? (Y/N): y
You have chosen yes
-bash: success_of_cloning_of_project1_repo3: command not found
-bash: success_of_cloning_of_project1_repo2: command not found
-bash: success_of_cloning_of_project1_repo1: command not found
-bash: success_of_cloning_of_project1_repo: command not found






command-line bash scripts






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 18 at 10:38







Jenny

















asked Mar 18 at 3:17









JennyJenny

865




865








  • 1





    Your terminal output and the script are inconsistent. The main() function calls project1_install_dir but there's no such function anywhere to be found in the script. But from your output colsim1_install_dir seems to be called first. Is project1_install_dir another script installed somewhere ? As for the output -bash: success_of_cloning_of_colsim1_utilities_repo3: it seems like function name got mangled with other function name.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:35











  • Sorry. There was a typo..both should be project1_install_dir. I have edited. sorry again.

    – Jenny
    Mar 18 at 3:40











  • No problems. So far I don't see any issue related to the error itself. You have a few places where variable $fullpath should be quoted and read -r -p should be used instead of just read -p , but these shouldn't be the cause of the error.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:53











  • Was this script ever on windows or anything that could have potentially inserted newline endings specific to DOS ? Do you use a non-English keyboard that could have entered different types of space characters ? I know with Chinese inputs there is a wide space character, which is different from ASCII space. Try doing cat -A ./scriptname.sh , maybe it will show special characters besides just $ line ending

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:59











  • No, it has never been on Windows. Yes I have a German keyboard. But I don't think I've ever used any German characters. cat -A ./scriptname.sh didn't show any special characters than $ signs

    – Jenny
    Mar 18 at 4:04
















  • 1





    Your terminal output and the script are inconsistent. The main() function calls project1_install_dir but there's no such function anywhere to be found in the script. But from your output colsim1_install_dir seems to be called first. Is project1_install_dir another script installed somewhere ? As for the output -bash: success_of_cloning_of_colsim1_utilities_repo3: it seems like function name got mangled with other function name.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:35











  • Sorry. There was a typo..both should be project1_install_dir. I have edited. sorry again.

    – Jenny
    Mar 18 at 3:40











  • No problems. So far I don't see any issue related to the error itself. You have a few places where variable $fullpath should be quoted and read -r -p should be used instead of just read -p , but these shouldn't be the cause of the error.

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:53











  • Was this script ever on windows or anything that could have potentially inserted newline endings specific to DOS ? Do you use a non-English keyboard that could have entered different types of space characters ? I know with Chinese inputs there is a wide space character, which is different from ASCII space. Try doing cat -A ./scriptname.sh , maybe it will show special characters besides just $ line ending

    – Sergiy Kolodyazhnyy
    Mar 18 at 3:59











  • No, it has never been on Windows. Yes I have a German keyboard. But I don't think I've ever used any German characters. cat -A ./scriptname.sh didn't show any special characters than $ signs

    – Jenny
    Mar 18 at 4:04










1




1





Your terminal output and the script are inconsistent. The main() function calls project1_install_dir but there's no such function anywhere to be found in the script. But from your output colsim1_install_dir seems to be called first. Is project1_install_dir another script installed somewhere ? As for the output -bash: success_of_cloning_of_colsim1_utilities_repo3: it seems like function name got mangled with other function name.

– Sergiy Kolodyazhnyy
Mar 18 at 3:35





Your terminal output and the script are inconsistent. The main() function calls project1_install_dir but there's no such function anywhere to be found in the script. But from your output colsim1_install_dir seems to be called first. Is project1_install_dir another script installed somewhere ? As for the output -bash: success_of_cloning_of_colsim1_utilities_repo3: it seems like function name got mangled with other function name.

– Sergiy Kolodyazhnyy
Mar 18 at 3:35













Sorry. There was a typo..both should be project1_install_dir. I have edited. sorry again.

– Jenny
Mar 18 at 3:40





Sorry. There was a typo..both should be project1_install_dir. I have edited. sorry again.

– Jenny
Mar 18 at 3:40













No problems. So far I don't see any issue related to the error itself. You have a few places where variable $fullpath should be quoted and read -r -p should be used instead of just read -p , but these shouldn't be the cause of the error.

– Sergiy Kolodyazhnyy
Mar 18 at 3:53





No problems. So far I don't see any issue related to the error itself. You have a few places where variable $fullpath should be quoted and read -r -p should be used instead of just read -p , but these shouldn't be the cause of the error.

– Sergiy Kolodyazhnyy
Mar 18 at 3:53













Was this script ever on windows or anything that could have potentially inserted newline endings specific to DOS ? Do you use a non-English keyboard that could have entered different types of space characters ? I know with Chinese inputs there is a wide space character, which is different from ASCII space. Try doing cat -A ./scriptname.sh , maybe it will show special characters besides just $ line ending

– Sergiy Kolodyazhnyy
Mar 18 at 3:59





Was this script ever on windows or anything that could have potentially inserted newline endings specific to DOS ? Do you use a non-English keyboard that could have entered different types of space characters ? I know with Chinese inputs there is a wide space character, which is different from ASCII space. Try doing cat -A ./scriptname.sh , maybe it will show special characters besides just $ line ending

– Sergiy Kolodyazhnyy
Mar 18 at 3:59













No, it has never been on Windows. Yes I have a German keyboard. But I don't think I've ever used any German characters. cat -A ./scriptname.sh didn't show any special characters than $ signs

– Jenny
Mar 18 at 4:04







No, it has never been on Windows. Yes I have a German keyboard. But I don't think I've ever used any German characters. cat -A ./scriptname.sh didn't show any special characters than $ signs

– Jenny
Mar 18 at 4:04












1 Answer
1






active

oldest

votes


















3














Pasting your code into https://www.shellcheck.net/ reports:



$ shellcheck myscript

Line 7:
read -p "Enter FULL folder path where you want to install project1:" fullpath
^-- SC2162: read without -r will mangle backslashes.

Line 9:
read -p "Continue? (Y/N): " confirm
^-- SC2162: read without -r will mangle backslashes.

Line 26:
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2162: read without -r will mangle backslashes.

Did you mean: (apply this, apply all SC2086)
if find "$fullpath"/project1/project1_repo -mindepth 1 | read; then

Line 36:
if [ -n "$(ls -A $DIR)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$DIR")" ]; then

Line 45:
if [ -d $fullpath/project1/project1_repo ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -d "$fullpath"/project1/project1_repo ]; then

Line 46:
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
[ -n "$(ls -A "$fullpath"/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"

Line 56:
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$fullpath"/project1/project1_repo)" ]; then


You can follow the suggestion to use "$fullpath" and any other recommendations in comments above. After fixing current errors ShellCheck reports, it may then report additional errors when you run it again.






share|improve this answer


























  • sudo upvote ;-)

    – Fabby
    Mar 18 at 20:00












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1126511%2fcommand-not-found-error-in-bash-script%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














Pasting your code into https://www.shellcheck.net/ reports:



$ shellcheck myscript

Line 7:
read -p "Enter FULL folder path where you want to install project1:" fullpath
^-- SC2162: read without -r will mangle backslashes.

Line 9:
read -p "Continue? (Y/N): " confirm
^-- SC2162: read without -r will mangle backslashes.

Line 26:
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2162: read without -r will mangle backslashes.

Did you mean: (apply this, apply all SC2086)
if find "$fullpath"/project1/project1_repo -mindepth 1 | read; then

Line 36:
if [ -n "$(ls -A $DIR)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$DIR")" ]; then

Line 45:
if [ -d $fullpath/project1/project1_repo ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -d "$fullpath"/project1/project1_repo ]; then

Line 46:
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
[ -n "$(ls -A "$fullpath"/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"

Line 56:
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$fullpath"/project1/project1_repo)" ]; then


You can follow the suggestion to use "$fullpath" and any other recommendations in comments above. After fixing current errors ShellCheck reports, it may then report additional errors when you run it again.






share|improve this answer


























  • sudo upvote ;-)

    – Fabby
    Mar 18 at 20:00
















3














Pasting your code into https://www.shellcheck.net/ reports:



$ shellcheck myscript

Line 7:
read -p "Enter FULL folder path where you want to install project1:" fullpath
^-- SC2162: read without -r will mangle backslashes.

Line 9:
read -p "Continue? (Y/N): " confirm
^-- SC2162: read without -r will mangle backslashes.

Line 26:
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2162: read without -r will mangle backslashes.

Did you mean: (apply this, apply all SC2086)
if find "$fullpath"/project1/project1_repo -mindepth 1 | read; then

Line 36:
if [ -n "$(ls -A $DIR)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$DIR")" ]; then

Line 45:
if [ -d $fullpath/project1/project1_repo ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -d "$fullpath"/project1/project1_repo ]; then

Line 46:
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
[ -n "$(ls -A "$fullpath"/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"

Line 56:
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$fullpath"/project1/project1_repo)" ]; then


You can follow the suggestion to use "$fullpath" and any other recommendations in comments above. After fixing current errors ShellCheck reports, it may then report additional errors when you run it again.






share|improve this answer


























  • sudo upvote ;-)

    – Fabby
    Mar 18 at 20:00














3












3








3







Pasting your code into https://www.shellcheck.net/ reports:



$ shellcheck myscript

Line 7:
read -p "Enter FULL folder path where you want to install project1:" fullpath
^-- SC2162: read without -r will mangle backslashes.

Line 9:
read -p "Continue? (Y/N): " confirm
^-- SC2162: read without -r will mangle backslashes.

Line 26:
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2162: read without -r will mangle backslashes.

Did you mean: (apply this, apply all SC2086)
if find "$fullpath"/project1/project1_repo -mindepth 1 | read; then

Line 36:
if [ -n "$(ls -A $DIR)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$DIR")" ]; then

Line 45:
if [ -d $fullpath/project1/project1_repo ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -d "$fullpath"/project1/project1_repo ]; then

Line 46:
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
[ -n "$(ls -A "$fullpath"/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"

Line 56:
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$fullpath"/project1/project1_repo)" ]; then


You can follow the suggestion to use "$fullpath" and any other recommendations in comments above. After fixing current errors ShellCheck reports, it may then report additional errors when you run it again.






share|improve this answer















Pasting your code into https://www.shellcheck.net/ reports:



$ shellcheck myscript

Line 7:
read -p "Enter FULL folder path where you want to install project1:" fullpath
^-- SC2162: read without -r will mangle backslashes.

Line 9:
read -p "Continue? (Y/N): " confirm
^-- SC2162: read without -r will mangle backslashes.

Line 26:
if find $fullpath/project1/project1_repo -mindepth 1 | read; then
^-- SC2086: Double quote to prevent globbing and word splitting.
^-- SC2162: read without -r will mangle backslashes.

Did you mean: (apply this, apply all SC2086)
if find "$fullpath"/project1/project1_repo -mindepth 1 | read; then

Line 36:
if [ -n "$(ls -A $DIR)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$DIR")" ]; then

Line 45:
if [ -d $fullpath/project1/project1_repo ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -d "$fullpath"/project1/project1_repo ]; then

Line 46:
[ -n "$(ls -A $fullpath/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
[ -n "$(ls -A "$fullpath"/project1/project1_repo)" ] && echo "Not Empty" || echo "Empty"

Line 56:
if [ -n "$(ls -A $fullpath/project1/project1_repo)" ]; then
^-- SC2086: Double quote to prevent globbing and word splitting.

Did you mean: (apply this, apply all SC2086)
if [ -n "$(ls -A "$fullpath"/project1/project1_repo)" ]; then


You can follow the suggestion to use "$fullpath" and any other recommendations in comments above. After fixing current errors ShellCheck reports, it may then report additional errors when you run it again.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 19 at 7:34









Melebius

5,09652040




5,09652040










answered Mar 18 at 10:52









WinEunuuchs2UnixWinEunuuchs2Unix

47.2k1190183




47.2k1190183













  • sudo upvote ;-)

    – Fabby
    Mar 18 at 20:00



















  • sudo upvote ;-)

    – Fabby
    Mar 18 at 20:00

















sudo upvote ;-)

– Fabby
Mar 18 at 20:00





sudo upvote ;-)

– Fabby
Mar 18 at 20:00


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1126511%2fcommand-not-found-error-in-bash-script%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How did Captain America manage to do this?

迪纳利

南乌拉尔铁路局