bk.
bk.

Reputation: 6288

Is the shell's `source` POSIX-standard?

I've spent some quality time searching the POSIX standard for the shell for the source and . commands, and am at this point convinced that they're just not in there.

Are there any shells that don't support the .? What is the POSIX-standard way of executing a shell script in the current environment (i.e., not spawning a subshell, so if the script says export VAR=value then VAR exists in the calling shell)?

I might be missing something obvious, but it turns out that . is not very easy to Google...

Upvotes: 33

Views: 10236

Answers (2)

Fred Foo
Fred Foo

Reputation: 363757

. is standardized (POSIX 2004, 2008).

source is non-standard and specifically not supported in ash, dash or pdksh (so probably it's not in the original Korn Shell either). I.e., it's a Bashism.

Upvotes: 27

Nemo
Nemo

Reputation: 71555

It's there under "dot".

NAME

dot - execute commands in the current environment

SYNOPSIS

. file

[etc.]

Upvotes: 34

Related Questions