[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: should this result in an endless loop ?
From: |
Lawrence Velázquez |
Subject: |
Re: should this result in an endless loop ? |
Date: |
Sat, 27 Nov 2021 14:30:02 -0500 |
User-agent: |
Cyrus-JMAP/3.5.0-alpha0-1371-g2296cc3491-fm-20211109.003-g2296cc34 |
Please stop randomly switching email addresses within your own
threads.
> On Sat, Nov 27, 2021, 20:06 Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com> wrote:
>
>> in the progress to represent another bug report about something, i made
>> this nonfunctional code
>>
>> printf '(( $# )) && . afile' >afile
>>
>> i run it with . afile a or bash afile a
>> then it ends up never ending
>> in set -x theres like dozens of '+' deep doing the code
A demonstration for the curious:
% cat >afile <<\EOF
heredoc> (( $# )) && . afile
heredoc> EOF
% bash -x afile a
+ (( 1 ))
+ . afile
++ (( 1 ))
++ . afile
+++ (( 1 ))
+++ . afile
++++ (( 1 ))
++++ . afile
+++++ (( 1 ))
+++++ . afile
[...]
On Sat, Nov 27, 2021, at 2:08 PM, ikhxcsz7y xmbott wrote:
> maybe the '. file' didnt apply 'noargs given'
Yes, when you run ''. afile'' without arguments, the positional
arguments are not cleared. The manual states this explicitly.
. filename [arguments]
Read and execute commands from the `filename` argument in the
current shell context. [...] If any `arguments` are supplied,
they become the positional parameters when `filename` is
executed. Otherwise the positional parameters are unchanged.
https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-_002e
--
vq