What is the best way of having a script that has it's own commands, which can be called at any stage in the script.
I'm sure there is a technical term for this type of CLI app which can help my search but I can't remember it.
sorry about the ambiguous title and question. Perhaps giving my specific use of this case might help, basically what I have is a script which finds all duplicates in a directory and asks "delete file?" with each set of duplicates. however during this I might find that I want to ignore all files in, say, the Mozilla directory. So I might issue a command like
> ignore "./Mozilla"
In the middle of the script. Is using trap with a function like "read...etc, case ...ignore...etc" the usual way of doing this? For example there are apps that have their own commands and their command line is prefixed by
>
is using trap to enter this mode in the middle of a script a good idea?
I do not think there is a need for trap, since you are looping through a list of files and/or directories and checking user input anyway for every delete. So instead of checking for y/n only you could check for "ignore" and take it from there.
There is one problem I have now though, I'm not asking for yes or no but a list of numbers that correspond to filenames in the shown set of duplicates. So I guess my follow up question is: what is the best way of checking whether the user input is a list of numbers separated by spaces, or not?