This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Use of SHELL env var by login


Andrey Repin wrote:
Greetings, Linda Walsh!

        Windows *doesn't* use "SHELL" to set your command line, it uses
COMSPEC.

Do note I didn't mention any specific variable names.
---
Indeed -- wanted to be explicit for those not know that the space
in-between the lines is important! ;-)

And I've explicitly outlined exactly the case you are describing in your post
- integration.
If you indeed have "more other" applications (native ports of certain tools,
which still use environment as a go-to reference sources), then by all means,
do what you find best for you.
I do that all the time, too, but I also have Cygwin itself configured to match
the environment I expect to have. Just to avoid issues.
---
	Yup -- I use the same site-wide login scripts (for me & root and
multi-machine) on linux and cygwin and regularly make sure to copy and test
them on both -- not to mean I don't have cygwin specific sections that
key off OS:
if ! type -f cygwin 2>/dev/null ; then read SYSTEM_KERNEL HOSTNAME OSTYPE <<<"$($_prg_uname -sno)"
   if [[ $OSTYPE =~ Cygwin ]]; then sub cygwin () { return 0; }
   else sub cygwin () { return 1; }
   fi
   export -f cygwin
 fi
# and some cygwin-only defs in /etc/local/cygwin, like
alias gvim='setsid gvim'              # ensure win-native vim backgrounds properly

and a version of "mklink" that runs in bash and uses the
*nix syntax of "mklink <from> <to>" (and auto-handles directories)

--------------------------------------------

#!/bin/bash #set -x
shopt -s expand_aliases extglob sourcepath

##
## func to help determine if we were called as script or lib &
## not dirty env if called as lib
##
function conditional_setprog {
 local lprogpath="$0"
 [[ $lprogpath =~ .*bash.* ]]  && { lprogpath="$1"; shift; }
 local lprog="${lprogpath##*/}" lprogdir="${lprogpath%/*}"
 local lprogname="${lprog%.*}"
 if [[ $lprogname =~ errnos ]]; then
   declare -g prog="$lprog" progpath="$lprogpath" progname="$lprogname"
 fi
}
conditional_setprog "$@"

#include stdalias
#include errnos
# --  include needed bits for fewer includes
alias intConst=declare\ -ir sub=function my=declare int=declare\ -i
intConst ENOENT=2 EEXIST=17 ENOSYS=38 ENOMSG=42


sub mklink ()  {
 sub err_ex {
   my err="${!1}" msg="$2"
   echo "$msg" >&2
   return $err
 }
if (($#!=2)) && [[ ! $0 =~ bash ]] ; then echo "mklink <from> <to-path|.> # (destination must not exist)" >&2
 fi
 local src=${1%/.} dst=${2%/.}; src=${src%/}
 [[ $dst == . ]] && dst="${src##*/}"
 [[ -e $dst ]] && {
   err_ex EEXIST "Destination, \"$dst\", already exists."
return } [[ -e $src ]] || { err_ex ENOENT "Source, \"$src\", does not exist."
   return
 }
 local dest_type="unknown"
 if [[ -f $src ]]; then dest_type=""
 elif [[ -d $src ]]; then dest_type="/d"
 else
   err_ex ENOSYS "Cannot determine src, \"$src\" as file or dir"
   return
 fi
 local winsrc windst
 printf -v winsrc "%s" "$(cygpath -wl "$src")"
 printf -v windst "%s" "$(cygpath -wl "$dst")"
 # windows reverses everything *nix
 # just to be different from CP/M which modeled Unix
 printf -v cmd 'cmd /c mklink %s "%q" "%q"' "$dest_type" "$windst" "$winsrc"
 eval "$cmd"
 (($?)) && err_ex ENOMSG "Windows return unexpected status($status)"
}
export -f mklink

(($#==0)) ||  [[ $0 =~ bash ]] || mklink "$@"
# vim: ts=2 sw=2
--------------------------

-linda

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]