help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] What is the different between `unset a[n-1]` in interact


From: Eduardo Bustamante
Subject: Re: [Help-bash] What is the different between `unset a[n-1]` in interactive mode and non-interactive mode?
Date: Mon, 17 Dec 2018 19:57:07 -0800

On Mon, Dec 17, 2018 at 5:56 PM Peng Yu <address@hidden> wrote:
(...)
> Why is there such a difference between the interactive mode and the
> non-interactive mode? Thanks.

Come on Peng. Can't you try to do at least some basic troubleshooting?

* run it with `set -x'
* check if you are using the same working directory
* are there any files that might match the glob?
* do you have any glob related shopt in your initialization files?
(nullglob perhaps?)
* did you try on another system?
* did you try running the script with `bash -i ./script' to force the
interactive mode?

See:

address@hidden:~$ bash foo
+ array=(a b c)
+ n=3
+ unset 'array[n-1]'
+ echo hxB
hxB

address@hidden:~$ bash -i foo
+ array=(a b c)
+ n=3
+ unset 'array[n-1]'
+ echo himxB
himxB

address@hidden:~$ bash -O nullglob -i foo
+ array=(a b c)
+ n=3
+ unset
+ echo himxB
himxB


If you just care about the answer: The argument to unset is processed
like any other argument. If it looks like a glob, and you don't want
that, then quote it.


On an unrelated topic: Please stop using help-bash as a dumping ground
for things you're too lazy to figure out on your own. Your technical
level should allow you to troubleshoot most of these things on your
own. Also, when people respond to you, you should at least follow up
indicating the final solution that you ended up using or a "thank you"
at least, no?

Cheers.



reply via email to

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