0

I wrote some shell scripts on bash on link: https://github.com/trouchet/sappio/blob/main/scripts/docker-utils.sh. However, I am unable to export them as terminal commands.

I thought, it would be simple to export it and use as bash aliases to its commands: run command bash docker-utils.sh from scripts folder. However, when I try command run sanitize from bash terminal, the output comes out:

Command 'sanitize' not found, did you mean:

  command 'sanitizer' from deb sanitizer (1.76-5)

Try: sudo apt install <deb name>

I tried already the command chmod +x ./scripts, but still get the same output.

  • The error means, the program is either not installed or it is not in your `PATH`. – Jetchisel Feb 17 '23 at 16:43
  • The command `export -f` in the script followed by the command name should suffice. Why does it not? – Bruno Peixoto Feb 17 '23 at 16:50
  • Are you executing the script or it is being sourced? – Jetchisel Feb 17 '23 at 16:52
  • `run command bash docker-utils.sh` You can't run, you need to source it. – KamilCuk Feb 17 '23 at 16:53
  • 1
    `export`ing a function makes it available to _child_ processes, not _parent_ processes. – Charles Duffy Feb 17 '23 at 17:24
  • @CharlesDuffy may you provide an example of your statement and set as an answer? – Bruno Peixoto Feb 17 '23 at 19:21
  • Because behavior is identical for exported variables and exported functions (which are just exported variables with special names that the shell looks for during initialization), and we have no end of questions already asked and answered about exported variables, no reason for a new answer; a duplicate flag suffices. – Charles Duffy Feb 17 '23 at 20:17
  • It's certainly a topic that's had a lot of thought (and at times dithering); if you go back to the Jeff Atwood blog posts in the early days talking about the philosophy behind Stack Overflow's design, there are posts talking about why we want to be diligent about closing duplicates, but also ones talking about why duplicates are helpful to the site (particularly when, as in this case, they use different terminology than the prior instances: that's part of why a question can still be upvoted even after being closed as duplicate, and dupes that get upvotes or inbound clicks aren't auto-deleted). – Charles Duffy Feb 17 '23 at 22:53
  • I see. I want 42 gold badges on my profile too :'-P. Do I earn some SO good guy certificate? – Bruno Peixoto Feb 18 '23 at 19:27

0 Answers0