The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

Views: 5,610     Votes:  4 
Tags: command-line   bash   scripts  
Link: 🔍 See Original Answer on Ask Ubuntu 🔗

URL: https://askubuntu.com/q/1126586
Title: Command not found error in Bash script
ID: /2019/03/18/Command-not-found-error-in-Bash-script
Created: March 18, 2019    Edited:  March 19, 2019
Upload: November 24, 2022    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


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.

⇧ How to standby a monitor using xset in multi monitor setup? Modeless/stateless layout language switching with Caps Lock, again (18.04 LTS Bionic Beaver)  ⇩