0

This is getting annoying on Monterey 12.2.1. I have a bash shell. I do not wish to make any changes to $HOME/.bashrc files.

What system file can I change?

This question is NOT THE SAME as:

[Restored Jul 6, 2022 at 6:07:42 PM]
Last login: Wed Jul  6 18:07:37 on console
Restored session: Mon Apr  4 12:32:47 EDT 2022

The default interactive shell is now zsh. To update your account to use zsh, please run chsh -s /bin/zsh. For more details, please visit https://support.apple.com/kb/HT208050. macbook$ /bin/bash

HOW do I quiet this extraneous output given that I wish to stay with bash SHELL.

nohillside
  • 100,768
  • 1
    How is this different than the linked question? It seems that the accepted answer is what you should do. – glenn jackman Jul 06 '22 at 22:39
  • To answer, I don't think there is a system file that controls this (I did check /etc/profile and all the files sourced from it), I think Apple compiled it into /bin/bash so that setting an environment variable will turn off the warning. – glenn jackman Jul 06 '22 at 22:39
  • 1
    Is there a specific reason you would like to not modify the .bashrc file? Are you aware of the .bash_profile file that can do the same thing as .bashrc for your purposes? – anonymousaga Jul 06 '22 at 22:53
  • One of the answers in the duplicate does give a system file to change /etc/profile and yes the warning is compiled into the bash binary - so use one of the several answers in the duplicate – mmmmmm Jul 06 '22 at 22:57
  • Glenn, that’s the answer. We cannot. It is baked (compiled) into the bash shell. – John Greene Jul 07 '22 at 12:29
  • But we can. Set one environment variable. – glenn jackman Jul 07 '22 at 12:34
  • My question is without changing the bash rc scripts. But put that as an answer. Key is. You can’t do it without changing it. It is not very Unix-like, much less BSD where macOS gets its root from. – John Greene Jul 07 '22 at 12:36
  • What changed is the macOS version, https://apple.stackexchange.com/a/422832/9058 explains the details. – nohillside Jul 07 '22 at 12:48
  • And you ask which system file you need to change. Change /etc/profile (or its bash companion) and you are done. – nohillside Jul 07 '22 at 12:52
  • @JohnGreene You have a very odd idea of what is "Unix-like". Such things are almost universally configured in rc files. The various bash startup files are just stubs in your $HOME for configuring however you like. – Marc Wilson Jul 08 '22 at 23:57
  • UNIX BOF do not encumber the STDOUT with unnecessary character not related to their original purpose much less kill off any legacy this way.

    ls still does what it did 40 year ago; macOS bash, not so much. The facts remains, Apple tainted STDOUT stream, and wants you to define certain things to get its originality back.

    – John Greene Jul 11 '22 at 12:40
  • @JohnGreene The bash delivered with macOS is as functional as ever, and I doubt the POSIX or Unix standards define what an interactive shell can print before the first prompt. Apple decided to compile the warning into the bash binary, they could have as well added it to /etc/profile. From a user perspective the situation would have been the same: it would require one edit in a system file to suppress the output. – nohillside Jul 11 '22 at 13:15
  • Of the millions of unit tests and integration tests that use Apple bash, notably when using with the expect utility, every single one of ALL their test scripts will have to be changed because Apple tainted the STDOUT by bash. Surely, you’d be not asking us to modify them all just because of the tainted by Apple STDOUT output, no? – John Greene Jul 11 '22 at 21:21
  • Wouldn't these tests and expect scripts also fail whenever somebody changed /etc/motd, or the version number of bash changed (ignoring for the moment that it might be safer to just rely on the shell prompt in such scripts)? Anyway, your question about how to disable the warning by changing a system file has been answered, hope the answer is useful. – nohillside Jul 12 '22 at 05:47
  • Non-login (Non-interactive or not) bash session do not evoke logind thereby not invoking /etc/motd, much less show a bash version. – John Greene Jul 12 '22 at 19:38
  • 1
    @JohnGreene And non-interactive shells don't display the warning message. – Marc Wilson Jul 14 '22 at 04:14
  • Clearly, your bash-based unit-tests does not do interactive bash (having default STDIN/STDOUT/STDERR). But many do. – John Greene Jul 14 '22 at 17:30

2 Answers2

5

do not wish to make any changes to $HOME/.bashrc files

Why, though? .bashrc and .profile files are exactly the place where this stuff lives. In my understanding Apple's version of bash checks the BASH_SILENCE_DEPRECATION_WARNING environment variable and displays the deprecation message if it's unset. I don't think it's any more complicated than just that.

given that you do really have these options:

  • install different version of bash via homebrew and use that instead of Apple's
  • configure it to not nag you about deprecation
  • accept zsh as inevitable
-2

You can change the default back to bash if you wish.

  1. Open up System Preferences: Users & Groups
  2. If the icon at the bottom is a closed lock, click that and enter your login password
  3. ^+click (or right click if you're using a mouse) on your login and select Advanced Options
  4. You'll see an entry for Login Shell, which you can change from the drop down.