19
1
My .bashrc
file contains a line to this effect:
alias prog="/path/to/script.sh $(find $(pwd) -name prog)"
When I comment out this line, Bash starts almost instantly when I open a new terminal. With this line, there is a 4-5 second delay before my cursor shows up.
Removing the nested commands $(pwd)
, etc. speeds it up again as well. Why is this happening? Can I still use nested commands somehow?
4The problem is the
find
command, which is execute at boot time and can take a long time to execute, depending on the directory structure. If you use single- instead of double-quotes,find
will be executed at run time, when thealias
is invoked. It depends on which working directory you want to use, that current at declaration time, or at run time. By the way$(pwd)
is a rather inefficient way to express.
or$PWD
. – AFH – 2017-05-14T22:14:40.80315
I know that's not what you are asking, but this looks a lot like a XY problem. Why do you need to locate the script using
– sleske – 2017-05-15T07:41:28.270find
? Once you installed it, you know where it is. Even if you update it frequently and change its name, you can maintain a symbolic link to it so it's always available under a fixed name.5@AFH Please post answers as answers, not comments. – David Richerby – 2017-05-15T11:31:28.613
1@DavidRicherby - I wanted to make sure that this was indeed the answer before posting. I was puzzled that the script would work on files found within an arbitrary directory. – AFH – 2017-05-15T14:13:18.817