From: Linda Walsh <cygwin@tlinx.org>
To: cygwin@cygwin.com
Subject: Re: Use of SHELL env var by login
Date: Tue, 27 Sep 2016 17:22:00 -0000 [thread overview]
Message-ID: <57EAA9C6.9020900@tlinx.org> (raw)
In-Reply-To: <1373245590.20160927194222@yandex.ru>
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
next prev parent reply other threads:[~2016-09-27 17:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-26 20:53 Ernie Rael
2016-09-27 2:24 ` Linda Walsh
2016-09-27 5:35 ` Ernie Rael
2016-09-27 11:20 ` Andrew Schulman
2016-09-27 13:13 ` Andrey Repin
2016-09-27 14:48 ` Andrew Schulman
2016-09-27 15:14 ` Andrey Repin
2016-09-27 16:50 ` Linda Walsh
2016-09-27 17:12 ` Andrey Repin
2016-09-27 17:22 ` Linda Walsh [this message]
2016-09-28 4:17 ` Ernie Rael
2016-09-27 17:18 ` Achim Gratz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=57EAA9C6.9020900@tlinx.org \
--to=cygwin@tlinx.org \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).