bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Feature request: Add "import" built-in.


From: Tim Friske
Subject: Feature request: Add "import" built-in.
Date: Sun, 24 Aug 2014 13:36:38 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

Hi,

as I see it the "source" built-in is perfect for embedding a sourced
Bash script into the sourcing one while preserving as much of the
environment, specifically the positional and special parameters, as
possible.

What I am missing is the "import" built-in that passes only the
explicitly given arguments from the importing to the imported Bash script.

I currently emulate the behavior I seek for with the following function:

function _import {
  local -r file="$1"
  set -- "${@:2}"
  source "$file" "$@"
}

For details please see my question and the answers on Unix & Linux
Exchange [1].

[1]
http://unix.stackexchange.com/questions/151889/why-does-bashs-source-command-behave-differently-when-called-from-a-function

Cheers
Tim

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]