Hi,
On Tue, 21 Jan 2014,
johngst...@gmail.com wrote:
> I would like to suppress the MOTD ("Welcome to Git ...") output in certain
> circumstances. My use case is for the next release of ComposerSetup, the
> windows installer for Composer:
>
https://github.com/johnstevenson/composer-setup
>
> It incorporates a shell context-menu feature which uses the cmd.exe to run
> various Composer commands. The next release allows the use of other console
> programs (Cygwin, Powershell, Msys, Git Bash, Console2 etc). For unixy
> variants I run a proxy/shim script in order to keep the console open after
> the command has run (so the user can see the result). And the next step
> asks the user if they want to continue, so I either allow the script to
> exit, or call $BASH --login -i to continue in the current directory.
>
> So for Git Bash it would be nice not to see the "Welcome ..." again. One
> solution is to set an environment variable in the shim script (export
> NOLOGO=1) then modify the user profile script as follows (line 130):
>
> test -f /etc/motd && [ -z "$NOLOGO" ] && sed "s/\$MESSAGE/$MESSAGE/" <
> /etc/motd
That looks pretty correct except for the mix between test and [: [ is
actually a synonym for test, and the ] is only syntactic sugar. Also, it
would be better to test the environment variable (cheap test) before the
file (more expensive test). So:
test -z "$NOLOGO" && test -f /etc/motd && sed ...
> My questions depend firstly on whether you would accept a PR for
> suppressing the MOTD, and are:
>
> 1) Is using an environment variable the way you would prefer to do this,
> rather than an additional command-line switch?
>
> 2) Is $NOLOGO the correct choice of env name or should it be more specific
> ($GIT_NOMOTD, $GIT_NOLOGO, for example) ?
My preference would be SKIP_MOTD.
Note that you could probably play some games by setting MESSAGE (a
variation of SQL injection) without having to come up with a patch ;-)
Ciao,
Johannes