2

My script use and modifies a shell variable. I need to always use:

source myscript

Is there a shorter way to call this script and have it modify the current shell's environment?

It can be elegantly done by using functions use as described in this answer, but I need a faster way.

Yurij73
  • 1,992
  • Do you mean faster as in - faster execution (performance), or faster setup (not having to modify .bashrc)? I ask because it never occurred to me wrapping it in a function would imply a performance deficit (if this is indeed the case). I suppose I could test this with time? – Emanuel Berg Sep 16 '12 at 21:51

1 Answers1

5

You can use . as a shorthand for source. From the bash(1) man page:

.  filename [arguments]
source filename [arguments]

Read and execute commands from filename in the current shell environment and return
the exit status of the last command executed from filename.
Michael Mrozek
  • 93,103
  • 40
  • 240
  • 233