[Top][All Lists]

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

Re: When "set -u", "which" outputs environment: line 1: _declare: unboun

From: Greg Wooledge
Subject: Re: When "set -u", "which" outputs environment: line 1: _declare: unbound
Date: Fri, 9 Apr 2021 16:22:38 -0400

On Fri, Apr 09, 2021 at 03:08:25PM -0400, Craig Andrews wrote:
> Description:
>         With "set -u", invoking "which" results in the output of:
> environment: line 1: _declare: unboundvariable
>         That should not happen, and does not happen, with prior versions of
> bash.
>         I'm using Fedora 34 (beta).
> Repeat-By:
>         Run this shell script:
>         #!/bin/bash
>         set -u
>         echo "$(which bash)"

I can think of two possible reasons for this:

1) which(1) on your system is a bash script, and the error message is
   coming from that script.

2) which on your system is a shell function, which is somehow made visible
   to the script that you ran (possibly having been exported through the
   environment, or declared in a file that's loaded via BASH_ENV).

Are you able to duplicate the error by running "which bash" in an
interactive shell, or does it only happen in scripts?

In whatever environment generates the error message, please run "type which"
to find out exactly how which is defined.

If it's a program (e.g. /usr/bin/which), please run "file" on that program
to see whether it's a (bash) script.

If it's a function, try to figure out where the function is being defined.

reply via email to

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