What are double colons :: in a shell script?

The :: is just a Naming Convention for function names. Is a coding-style such as snake_case or CamelCase The convention for Function names in shell style commonly is: Lower-case, with underscores to separate words. Separate libraries with ::. Parentheses are required after the function name. The keyword function is optional, but must be used consistently … Read more

Getting compgen to include slashes on directories when looking for files

I ran into the same problem. Here’s the workaround I’m using: Register the completion function with -o default, e.g., complete -o default -F _my_completion. When you want to complete a filename, just set COMPREPLY=() and let Readline take over (that’s what the -o default does). There’s a potential problem with this — you might be … Read more

What does -n mean in Bash?

The -n argument to test (aka [) means “is not empty”. The example you posted means “if $1 is not not empty. It’s a roundabout way of saying [ -z “$1” ]; ($1 is empty). You can learn more with help test. $1 and others ($2, $3..) are positional parameters. They’re what was passed as … Read more