Advice on suppressing MOTD message

244 views
Skip to first unread message

johngst...@gmail.com

unread,
Jan 21, 2014, 7:14:37 AM1/21/14
to msy...@googlegroups.com
Hi,

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

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) ?

Thanks

John Stevenson

Johannes Schindelin

unread,
Jan 22, 2014, 11:31:49 AM1/22/14
to johngst...@gmail.com, msy...@googlegroups.com
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

johngst...@gmail.com

unread,
Jan 22, 2014, 3:16:16 PM1/22/14
to msy...@googlegroups.com, johngst...@gmail.com

On Wednesday, 22 January 2014 16:31:49 UTC, Johannes Schindelin wrote:


That looks pretty correct except for the mix between test and [: [ is
actually a synonym for test, and the ] is only syntactic sugar.

 Thank you for improving my limited shell-scripting knowledge.

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 ;-)

I already tried playing and lost (see above)! Using SKIP_MOTD seems a more descriptive and therefore more robust solution, so I will go with that.

Thanks
John

ahmetal...@gmail.com

unread,
Mar 26, 2015, 5:03:57 AM3/26/15
to msy...@googlegroups.com, johngst...@gmail.com
This has a pull request now https://github.com/msysgit/msysgit/pull/302
Reply all
Reply to author
Forward
0 new messages