Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

shellenv.sh: csh/tcsh: Broken code for setting envvar MANPATH #17949

Closed
3 tasks done
eeide opened this issue Aug 3, 2024 · 1 comment · Fixed by #17951
Closed
3 tasks done

shellenv.sh: csh/tcsh: Broken code for setting envvar MANPATH #17949

eeide opened this issue Aug 3, 2024 · 1 comment · Fixed by #17951
Labels
bug Reproducible Homebrew/brew bug

Comments

@eeide
Copy link

eeide commented Aug 3, 2024

brew doctor output

admin@noir ~ % which brew
/opt/homebrew/bin/brew
admin@noir ~ % brew doctor
Your system is ready to brew.
admin@noir ~ %

Verification

  • My "brew doctor output" above says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update twice and am still able to reproduce my issue.
  • This issue's title and/or description do not reference a single formula e.g. brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.

brew config output

admin@noir ~ % brew config
HOMEBREW_VERSION: 4.3.12
ORIGIN: https://github.com/Homebrew/brew
HEAD: 874d2da45344d3b27aa740e555b0210d8c474220
Last commit: 4 days ago
Core tap JSON: 03 Aug 17:13 UTC
Core cask tap JSON: 03 Aug 17:13 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.4/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 15.0.0 build 1500
Git: 2.46.0 => /opt/homebrew/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 14.6-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: 15.4
Rosetta 2: false

What were you trying to do (and why)?

After updating to macOS 14.6 (Sonoma) and current Homebrew, I tried to start a login tcsh shell. My ~/.cshrc contains the following code:

set noglob
eval `/opt/homebrew/bin/brew shellenv`
unset noglob

I tried creating this shell because I wanted to use the shell to execute other commands.

What happened (include all command output)?

The configuration of the tcsh shell encountered an error. The terminal showed:

Last login: Sat Aug  3 11:19:12 on ttys006
MANPATH: Undefined variable.
[noir:~] eeide%

Tracking this down, I traced the problem to this line in shellenv.sh:

echo "if ( \${?MANPATH} == 1 ) setenv MANPATH :\${MANPATH};"

When executed in a shell in which MANPATH is not already set, the shell code output by that line (which is intended to be eval'ed by tcsh) yields an error. This is exemplified by the following tcsh transcript:

[noir:~] eeide% unsetenv MANPATH
[noir:~] eeide% if ( ${?MANPATH} == 1 ) setenv MANPATH :${MANPATH};
MANPATH: Undefined variable.

What did you expect to happen?

I expected no error to be caused by the code that is output by brew shellenv.

In particular, I expected that there would not be an error relating the setting of MANPATH when I created a login shell with tcsh.

Step-by-step reproduction instructions (by running brew commands)

* Start a `tcsh` shell.
* In that shell, execute the following commands. (The setting of `PATH` is required to get `brew shellenv` to output commands.)


setenv PATH /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin
unsetenv MANPATH
eval `/opt/homebrew/bin/brew shellenv`
  • Observe the error output by the last of the above commands:
% eval `/opt/homebrew/bin/brew shellenv`
MANPATH: Undefined variable.
@eeide eeide added the bug Reproducible Homebrew/brew bug label Aug 3, 2024
@eeide
Copy link
Author

eeide commented Aug 3, 2024

Similarly, the emitted code for setting envvar INFOPATH raises an error when INFOPATH is not already set.

@Bo98 Bo98 closed this as completed in 3fec77e Aug 3, 2024
ctaintor pushed a commit to ctaintor/brew that referenced this issue Sep 4, 2024
It turns out that control flow in csh is a pain. But we can rely on
`test`, which is thankfully POSIX.

Closes Homebrew#17949.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Reproducible Homebrew/brew bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant