From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2324 invoked by alias); 7 Apr 2018 20:27:57 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23317 Received: (qmail 14729 invoked by uid 1010); 7 Apr 2018 20:27:57 -0000 X-Qmail-Scanner-Diagnostics: from mta04.eastlink.ca by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(24.224.136.10):SA:0(-2.6/5.0):. Processed in 1.322213 secs); 07 Apr 2018 20:27:57 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: rayandrews@eastlink.ca X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset=utf-8; format=flowed X-Authority-Analysis: v=2.3 cv=IOss9DnG c=1 sm=1 tr=0 a=RnRVsdTsRxS/hkU0yKjOWA==:117 a=RnRVsdTsRxS/hkU0yKjOWA==:17 a=IkcTkHD0fZMA:10 a=wbDR2PszRdDZFro1K_IA:9 a=QEXdDO2ut3YA:10 X-EL-IP-NOAUTH: 24.207.101.9 Subject: Re: activate alias inside subshell To: zsh-users@zsh.org References: <604319cb-d86f-686b-ac9b-00d21650edff@eastlink.ca> From: Ray Andrews Message-id: <637434d9-ff23-53d4-5d31-443942fc2ef9@eastlink.ca> Date: Sat, 7 Apr 2018 12:57:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 In-reply-to: <604319cb-d86f-686b-ac9b-00d21650edff@eastlink.ca> Content-language: en-CA > Some elegant solution? > > " As a consequence, aliases defined in a function are not > available until after that function is executed. To be safe, > always put alias definitions on a separate line, and do not use > alias in compound commands. > > And another quote, this time from |zsh| manual: > > There is a commonly encountered problem with aliases illustrated > by the following code: > > |alias echobar='echo bar';echobar| > > This prints a message that the command echobar could not be found." > Ok, that is clear.  Too bad whence seems to report the thing as active, that had me beating my head against the wall.  Something like a runtime expansion would be a nice option to have but it seems that unheard of.   But another mystery: mag=$'\e[35;1m' cyn=$'\e[36;1m' nrm=$'\e[0m' yelline () { echo -e "$yel$@$nrm" } function msg () { echo -e "${grn}$@${nrm}" } alias msg='yelline ${(%):-%x %I}:' function test1 () { ( whence -va msg; declare -f msg msg one msg () { echo nulled } whence -va msg; declare -f msg msg where has the alias gone? echo "\n==========================\n" ) } Output:     $ . test1; test1 msg is an alias for yelline ${(%):-%x %I}: <<  fine msg is a shell function from test1                  << fine, function is right and alias is there msg () {     echo -e "${grn}$@${nrm}" } test1 14: one <<  fine, the alias is  in effect. msg is an alias for yelline ${(%):-%x %I}:     << ok .. msg is a shell function from test1                 << ... but the function is not updated and ... msg () {     echo -e "${grn}$@${nrm}" } nulled                                                  << ... the changed function now overrides the alias! ... in practice this is exactly what I need in the current situation -- to kill either function or alias, but it does seem strange that changing a function causes it to override an alias.  Is this documented somewhere? >