I noticed that the bash shell can suggest command line switches for your command.
Just type your command, a dash (-) and type tab. The shell will show you available switches.
For example, try:
andy@andyx:~$ java -
and press tab - Surprise!
The question is:
How do I interface with this feature. I.e., if I write a program that is to be run from the console, what's the API to tell the shell what switches are available?
A command-line switch is a modifier that is added to the .exe file. A startup file with a switch looks like this. outlook.exe /nopreview. In this example, a command-line switch has been added to the .exe file for Microsoft Outlook.
. (dot) runs a shell script in the current environment and then returns. Normally, the shell runs a command file in a child shell so that changes to the environment by such commands as cd, set, and trap are local to the command file. The . (dot) command circumvents this feature.
A file with . sh extension is a scripting language commands file that contains computer program to be run by Unix shell. It can contain a series of commands that run sequentially to carry out operations such as files processing, execution of programs and other such tasks.
The source Command The built-in bash source command reads and executes the content of a file. If the sourced file is a bash script, the overall effect comes down to running it. We may use this command either in a terminal or inside a bash script.
You have discovered Bash's programmable completion feature.
See:
$ man bash
In particular, the section entitled "READLINE" and subsection "Programmable Completion"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With