|
From: | Linda Walsh |
Subject: | Re: how are aliases exported? |
Date: | Sun, 15 Apr 2012 13:52:02 -0700 |
User-agent: | Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
Pierre Gaston wrote:
2) non-interactive bash Aliases are off by default. So given that you need to run something at the beginning of your new bash instance anyway, you could define your aliases in a function together with the mandatory shopt, eg: function start_aliases { shopt -s expand_aliases alias foo=ls } export -f start_aliases Then you can do: bash <<< $'start_aliases\nfoo' Note that the function need to be on a line before the first use of the alias, eg bash -c 'start_aliases;foo' doesn't work. You can even make a kinda of export alias function with a hack like: function start_aliases { shopt -s expand_aliases eval "$my_aliases" }
--- Right... that's what I was going for as a work around. But I want the syntax include file.shh to just 'work', i.e. first time, it would call my include file, which defines the function... but then when I include stuff in file.ssh, my include file won't know what is in it. So I can't very well go and apply "-g" to everything -- I just need it to execute in the top context. not from within a function. The only way I see to do that is using an alias with an eval of the contents of the include... Then everything is as if it was simply 'sourced'... Except that you can include include Math/Simple.shh and it will still look it up on your path.
[Prev in Thread] | Current Thread | [Next in Thread] |