You are not logged in.
To execute scripts in your PWD without prepending them with "./", add it to the end of your $PATH:
$ export PATH="$PATH:."
...and, to make it permanent, create an entry in your .bashrc:
$ echo "export PATH=\"\$PATH:.\"" >> ~/.bashrc
It won't cure cancer, I just think it's cool
(02/05/2009) Replaced the old title with one more descriptive.
Last edited by deltaecho (2009-02-06 03:47:41)
Dylon
Offline
As a (not-so-closet) paranoid, I feel it necessary to mention that, while maybe somewhat convenient, this is a potential security risk. If you're in a directory where somebody else has write permissions, you could end up running a program of their choosing which (especially if you're root) could have disastrous consequences. There are some people who consider adding "." to PATH tantamount to heresy. I am nearly in that camp. Caveat emptor. Know what you're doing, and what the risks are. And have fun.
Offline
I thought about that, and wondered how others felt. By placing "." at the end of the $PATH variable, I decided there was much less of a chance of unintentionally executing any script or executable file in your current directory, because any executable -- with the same name -- in your $PATH listed before it would get 1st priority (in such a situation you would HAVE to type ./<scriptname> to run it). As such, if I decide to keep my $PATH as it is, do you think my security could still potentially be compromised?
Dylon
Offline
I'd say there still is a risk, because many applications will test for the presence of a helper application simply by trying to call it (for example with -v) and seeing if the command is found. Of course that's arguably bad practice on their part, but it's still pretty common in simpler scripts (I think).
Besides, I must say I like to keep a distinction between static executables called through my path and local, context-dependent ones needing "./". JIt just feels cleaner somehow.
Last edited by Arkane (2009-02-06 08:34:35)
What does not kill you will hurt a lot.
Offline
I have ~/bin in my path, so anything that I need to run regularly goes in there. For ad-hoc stuff, I can live with ./foo.
Offline
I have ~/bin in my path, so anything that I need to run regularly goes in there. For ad-hoc stuff, I can live with ./foo.
+1
Just as convenient and less risky imo.
I made it long
as I lacked the time to make it short...
Offline
Yeah, ditto on ~/bin being a good solution - if I need to reuse it often, I'll put it (or symlink it) there. I find the two extra characters worth the security.
Offline
I kept my scripts in /usr/local/bin but now I've moved them all to ~/.bin
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
I have ~/bin in my path, so anything that I need to run regularly goes in there
+2
There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums. That is why we avoid it. -- ewaller (arch linux forum moderator)
Offline
I put all my scripts-in-progress in ~/Workspace/Development/Scripts, and move them to /usr/local/bin when they become "production ready," but every now and then, I create a semi-random folder in which I create a script I only need temporarily; it's nice to be able to quickly create a script and run it with only its name, despite the fact prepending it with "./" only adds 2 more characters.
I'd say there still is a risk, because many applications will test for the presence of a helper application simply by trying to call it (for example with -v) and seeing if the command is found. Of course that's arguably bad practice on their part, but it's still pretty common in simpler scripts (I think).
@Arkane, could you give me some examples?
Dylon
Offline
but every now and then, I create a semi-random folder
what is a semi-random folder?
Offline
"Semi-random" as in I decide I need to create a script and "mkdir $SOME_RANDOM_NAME_FROM_THE_TOP_OF_MY_HEAD," whether that be "temp," or "<scriptname>-dir," or whatever else.
Dylon
Offline