I apologize in advance, I'm not good at writing shell scripts.
I have a bash function that looks like this:
tagDownload() {
mp3 "$@" | /home/username/bin/tag.py
}
where mp3
is another bash function that produces some output that is used by the python script. This function is stored in a dotfile that is sourced whenever a terminal is opened.
What I expect (and want) to happen is for tagDownload
and its constituent components to only be invoked when called. What is actually happening is that the python script is invoked when the dotfile that houses this definition is sourced when a new terminal is opened.
I have two questions:
- How should I structure
tagDownload
so that when its parent file is sourced, the python program isn't invoked? - What rules does bash use to determine if something is an invocation vs a statement? I've had problems with this before and want to avoid such headaches in the future.
If I'm thinking about this incorrectly, please, correct me.
tagDownload
somewhere later in your dotfile?tagDownload
somewhere, or to the Python script. Useset -x
at the top of the file to see what's happening when a terminal is opened.