Mail Archives: cygwin/2002/07/11/13:12:20
> -----Original Message-----
> From: Jon LaBadie
>
> On Wed, Jul 10, 2002 at 12:44:19PM -0500, Polley Christopher W wrote:
> >
> > > From: Jon LaBadie
> > >
> > > One thing I would like to do is replace "set SHELL=/bin/ksh" with
> > >
> > > SHELL=$(grep "^${USER}:" /etc/passwd | cut -d: -f7)
> > > : ${SHELL:=/bin/ksh}
> > >
> >
> > How about:
> >
> > ------>8--------
> > @echo off
> >
> > C:
> > chdir \cygwin\bin
> >
> > rem set SHELL to user's shell (from /etc/passwd)
> > bash -c "echo -n 'set SHELL='> temp_setShellEnvVar.bat"
> > grep "^%USERNAME%:" /etc/passwd | cut -d: -f7 >>
> temp_setShellEnvVar.bat
> > call temp_setShellEnvVar.bat
> > del temp_setShellEnvVar.bat
> >
> > rxvt --loginShell -geometry 108x32 -fn 10x20 -sr +ut
> >
> > ------>8--------
> >
> > (window's 'echo' is unable to write to a line without a
> crlf at the end, and
> > AFAIK, there's no backtick equivalent in batch programming)
>
> Chris,
> first tests show it working. I never considered mixing
> cygwin calls in a .bat.
>
> To save me from learning batch file programming, one last
> thing please.
>
> The possibility exists that column seven in /etc/passwd is
> empty (a valid situation).
> In that case the code would be setting SHELL= , i.e. a null
> value. I'd like to
> supply a default (probably /bin/bash). In shell it would be
> easy, in batch I
> guess it would take an if statement (assuming they exist in
> batch). The cumbursome
> shell way would be something like:
>
> if [[ ${SHELL} = "" ]]
> then
> export SHELL=/bin/bash
> fi
>
> Would something similar be available in batch? A guess:
>
> if %SHELL% = "" set SHELL=/bin/passwd
>
This is close, but when doing string comparisons in batch, you need to quote
both sides:
if "%SHELL%" = "" set SHELL=/bin/bash
-Chris
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -