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,922
  • 6
  • 20
  • 32
  • 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
  • 91,316
  • 38
  • 238
  • 232
  • Note that `.` is the POSIX standard name for this command (`source` is a bash-specific synonym). – chepner Sep 22 '12 at 04:40