外部コマンドを実行しようとしたときにCygwin Bashが常に端末から読み取られるのはなぜですか?

外部コマンドを実行しようとしたときにCygwin Bashが常に端末から読み取られるのはなぜですか?

これはパスが不完全であり、「コマンドが見つからない問題」ではありません。外部コマンド現れる確認を開始し、 今探してください端末出力を生成する代わりに端末入力。

.profile/.bashrc ファイルなどをフラッシュしたようですが... 問題の原因を見ることができません。

私はmintty 2.5.1(i686-pc-cygwin)を使用してcygwin bashを対話的に起動します。一部のスクリプトを実行すると、$ プロンプトが表示されます。 shopt -x が設定され、コマンドがエコーされるのを見ることができます。

(MinGWもインストールされており、cygwin以降のDOSパスにあります。)

私が入力したすべての外部コマンドは、端末から行を読み取って応答します。 $プロンプトを再表示する唯一の方法は、Ctrl-Cを押してEnterを押すことです。

これは、cygwinが起動したスクリプトから始まるターミナル出力です。たぶん前のどこかに私の間違いがあるかもしれません。最後に、「mount」と「man mount」コマンドを実行してみました。このコマンドは、前に "+" (shopt -x で) が付いたコマンドをエコーし​​、入力を読み込みます。

    + '[' -z '' ']'
    + : /usr/bin:/c:/c/tools:/c/WINDOWS/System32:/c/WINDOWS:/c/WINDOWS/System32/WBEM:/c/WINDOWS/system32/WindowsPowerShell/v1.0:/c/cgywin/bin:/c/MinGW/bin:/c/Documents and Settings/All Users/Application Data/Oracle/Java/javapath:/c/Program Files/rexx.org/Regina:/c/Program Files/rexx.org/THE
    + '[' addwinpath = addwinpath ']'
    + PATH='/usr/local/bin:/usr/bin:/usr/bin:/c:/c/tools:/c/WINDOWS/System32:/c/WINDOWS:/c/WINDOWS/System32/WBEM:/c/WINDOWS/system32/WindowsPowerShell/v1.0:/c/cgywin/bin:/c/MinGW/bin:/c/Documents and Settings/All Users/Application Data/Oracle/Java/javapath:/c/Program Files/rexx.org/Regina:/c/Program Files/rexx.org/THE'
    + INFOPATH=/usr/local/info:/usr/share/info:/usr/info
    ++ /usr/bin/id -un
    + USER=User
    + unset TMP TEMP
    + TMP=/tmp
    + TEMP=/tmp
    + p='/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device'
    + '[' -e '/proc/registry/HKEY_CURRENT_USER/Software/Microsoft/Windows NT/CurrentVersion/Windows/Device' ']'
    + read -r PRINTER
    + PRINTER='HP LaserJet Professional P1606dn'
    + unset p
    + umask 022
    + '[' '!' -d '/c/Documents and Settings/User' ']'
    + readonly PROFILEREAD=true
    + PROFILEREAD=true
    + '[' '!' -z '' ']'
    + cd '/c/Documents and Settings/User'
    ++ /usr/bin/hostname
    + HOSTNAME=hej
    + profile_d sh
    + _LC_ALL_SET_=
    + _LC_SAVE_=null
    + LC_ALL=C
    + '[' null = null ']'
    + for file in '/etc/profile.d/*.$1'
    + '[' -e /etc/profile.d/lang.sh ']'
    + . /etc/profile.d/lang.sh
    ++ test -z ''
    +++ /usr/bin/locale -uU
    ++ export LANG=en_US.UTF-8
    ++ LANG=en_US.UTF-8
    + for file in '/etc/profile.d/*.$1'
    + '[' -e /etc/profile.d/tzset.sh ']'
    + . /etc/profile.d/tzset.sh
    ++ test -z ''
    +++ /usr/bin/tzset
    ++ export TZ=America/New_York
    ++ TZ=America/New_York
    + unset LC_ALL
    + unset file
    + unset _LC_ALL_SET_
    + unset _LC_SAVE_
    + '[' '!' 'x4.3.46(6)-release' = x ']'
    + '[' -f /etc/bash.bashrc ']'
    + . /etc/bash.bashrc
    ++ [[ -z '' ]]
    ++ CYG_SYS_BASHRC=1
    ++ [[ himxBH != *i* ]]
    ++ export 'EXECIGNORE=*.dll'
    ++ EXECIGNORE='*.dll'
    ++ PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
    + export PROFILEREAD PATH ORIGINAL_PATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL
    + echo '.profile in  C:\Documents and Settings\User\.profile'
    .profile in  C:\Documents and Settings\User\.profile
    + set -x
    ++ uname -o
    + [[ Cygwin == \C\y\g\w\i\n ]]
    + export CYGDRIVE=/cygdrive
    + CYGDRIVE=/cygdrive
    + export 'PATH=./://cygdrive/c/bin:/usr/local/bin:/usr/bin:/usr/bin:/c:/c/tools:/c/WINDOWS/System32:/c/WINDOWS:/c/WINDOWS/System32/WBEM:/c/WINDOWS/system32/WindowsPowerShell/v1.0:/c/cgywin/bin:/c/MinGW/bin:/c/Documents and Settings/All Users/Application Data/Oracle/Java/javapath:/c/Program Files/rexx.org/Regina:/c/Program Files/rexx.org/THE:/c/Documents and Settings/User'
    + PATH='./://cygdrive/c/bin:/usr/local/bin:/usr/bin:/usr/bin:/c:/c/tools:/c/WINDOWS/System32:/c/WINDOWS:/c/WINDOWS/System32/WBEM:/c/WINDOWS/system32/WindowsPowerShell/v1.0:/c/cgywin/bin:/c/MinGW/bin:/c/Documents and Settings/All Users/Application Data/Oracle/Java/javapath:/c/Program Files/rexx.org/Regina:/c/Program Files/rexx.org/THE:/c/Documents and Settings/User'
    + export HOME=/cygdrive/g/GNU-GCC/home/User
    + HOME=/cygdrive/g/GNU-GCC/home/User
    + cd /cygdrive/g/GNU-GCC/home/User
    + '[' -f /cygdrive/g/GNU-GCC/home/User/.bashrc ']'
    + . /cygdrive/g/GNU-GCC/home/User/.bashrc
    ++ set -o notify
    ++ set -o noclobber
    ++ set -o ignoreeof
    ++ set -o nounset
    ++ set -o xtrace
    ++ alias 'debug=set -o nounset; set -o xtrace'
    ++ ulimit -S -c 0
    ++ shopt -s checkhash
    ++ shopt -s checkwinsize
    ++ shopt -s sourcepath
    ++ shopt -s no_empty_cmd_completion
    ++ shopt -s cmdhist
    ++ shopt -s histappend histreedit histverify
    ++ shopt -s extglob
    ++ shopt -s nocaseglob
    ++ shopt -s expand_aliases
    ++ shopt -u cdspell
    ++ shopt -u cdable_vars
    ++ shopt -u mailwarn
    ++ unset MAILCHECK
    ++ alias cls=clsb
    ++ set +u
    ++ [[ -z '' ]]
    ++ unalias cls
    ++ alias 'cls=tput reset'
    ++ set -u
    ++ alias 'rm=rm -i'
    ++ alias 'cp=cp -i'
    ++ alias 'mv=mv -i'
    ++ alias h=history
    ++ alias 'j=jobs -l'
    ++ alias 'which=type -a'
    ++ alias '..=cd ..'
    ++ alias 'path=echo -e ${PATH//:/\\n}'
    ++ alias 'libpath=echo -e ${LD_LIBRARY_PATH//:/\\n}'
    ++ alias 'du=du -kh'
    ++ alias 'df=df -kTh'
    ++ alias 'pushnullglob=local nullglob=$(shopt -p nullglob) ; shopt -s nullglob'
    ++ alias 'popnullglob=$nullglob ; unset nullglob'
    ++ alias 'ls=ls -h --color'
    ++ alias 'lx=ls -lXB'
    ++ alias 'lk=ls -lSr'
    ++ alias 'lt=ls -ltr'
    ++ alias 'lc=ls -ltcr'
    ++ alias 'lu=ls -ltur'
    ++ alias 'll=ls -lv --group-directories-first'
    ++ alias 'lm=ll |more'
    ++ alias 'lr=ll -R'
    ++ alias 'la=ll -A'
    ++ alias 'tree=tree -Csuh'
    ++ alias more=less
    ++ export PAGER=less
    ++ PAGER=less
    ++ export LESSCHARSET=latin1
    ++ LESSCHARSET=latin1
    ++ export 'LESSOPEN=|/usr/bin/lesspipe.sh %s 2>&-'
    ++ LESSOPEN='|/usr/bin/lesspipe.sh %s 2>&-'
    ++ export 'LESS=-i -w -s -z-4 -g -M -X -r -f -P%t?f%f \
    :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...'
    ++ LESS='-i -w -s -z-4 -g -M -X -r -f -P%t?f%f \
    :stdin .?pb%pb\%:?lbLine %lb:?bbByte %bb:-...'
    ++ export 'LESS_TERMCAP_mb='
    ++ LESS_TERMCAP_mb=''
    ++ export 'LESS_TERMCAP_md='
    ++ LESS_TERMCAP_md=''
    ++ export 'LESS_TERMCAP_me='
    ++ LESS_TERMCAP_me=''
    ++ export 'LESS_TERMCAP_se='
    ++ LESS_TERMCAP_se=''
    ++ export 'LESS_TERMCAP_so='
    ++ LESS_TERMCAP_so=''
    ++ export 'LESS_TERMCAP_ue='
    ++ LESS_TERMCAP_ue=''
    ++ export 'LESS_TERMCAP_us='
    ++ LESS_TERMCAP_us=''
    ++ export -f wcd
    ++ [[ C:\Documents and Settings\User == \C\:\\\U\s\e\r\s\\\j\a\r\e\d ]]
    ++ export GNUGCC=/cygdrive/g/GNU-GCC
    ++ GNUGCC=/cygdrive/g/GNU-GCC
    ++ alias 'stamp=export STAMP=`date +D%Y%m%d.T%H%M%S`; export LOGS=`pwd`/logs/${STAMP};  mkdir -pv ${LOGS}'
    ++ alias 'gcd=cd /cygdrive/g/GNU-GCC/toolchain-avr'
    ++ alias 'gcc=cd /cygdrive/g/GNU-GCC/toolchain-avr/gcc-build; stamp; ../gcc/libgcc/configure'
    ++ alias 'avr=gcd; stamp; (build_package-avr-gcc.bash "$STAMP" "$LOGS" 2>&1) | tee $LOGS/_package.log'
    ++ alias 'avo=gcd; stamp; (package-avr-gcc.bash 2>&1) | tee $LOGS/_package.log'
    ++ alias -p
    alias ..='cd ..'
    alias avo='gcd; stamp; (package-avr-gcc.bash 2>&1) | tee $LOGS/_package.log'
    alias avr='gcd; stamp; (build_package-avr-gcc.bash "$STAMP" "$LOGS" 2>&1) | tee $LOGS/_package.log'
    alias cls='tput reset'
    alias cp='cp -i'
    alias debug='set -o nounset; set -o xtrace'
    alias df='df -kTh'
    alias du='du -kh'
    alias gcc='cd /cygdrive/g/GNU-GCC/toolchain-avr/gcc-build; stamp; ../gcc/libgcc/configure'
    alias gcd='cd /cygdrive/g/GNU-GCC/toolchain-avr'
    alias h='history'
    alias j='jobs -l'
    alias la='ll -A'
    alias lc='ls -ltcr'
    alias libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
    alias lk='ls -lSr'
    alias ll='ls -lv --group-directories-first'
    alias lm='ll |more'
    alias lr='ll -R'
    alias ls='ls -h --color'
    alias lt='ls -ltr'
    alias lu='ls -ltur'
    alias lx='ls -lXB'
    alias more='less'
    alias mv='mv -i'
    alias path='echo -e ${PATH//:/\\n}'
    alias popnullglob='$nullglob ; unset nullglob'
    alias pushnullglob='local nullglob=$(shopt -p nullglob) ; shopt -s nullglob'
    alias rm='rm -i'
    alias stamp='export STAMP=`date +D%Y%m%d.T%H%M%S`; export LOGS=`pwd`/logs/${STAMP};  mkdir -pv ${LOGS}'
    alias tree='tree -Csuh'
    alias which='type -a'

    User@hej ~
    $ shopt
    + shopt
    autocd          off
    cdable_vars     off
    cdspell         off
    checkhash       on
    checkjobs       off
    checkwinsize    on
    cmdhist         on
    compat31        off
    compat32        off
    compat40        off
    compat41        off
    compat42        off
    complete_fullquote      on
    direxpand       off
    dirspell        off
    dotglob         off
    execfail        off
    expand_aliases  on
    extdebug        off
    extglob         on
    extquote        on
    failglob        off
    force_fignore   on
    globstar        off
    globasciiranges off
    gnu_errfmt      off
    histappend      on
    histreedit      on
    histverify      on
    hostcomplete    on
    huponexit       off
    interactive_comments    on
    lastpipe        off
    lithist         off
    login_shell     on
    mailwarn        off
    no_empty_cmd_completion on
    nocaseglob      on
    nocasematch     off
    nullglob        off
    progcomp        on
    promptvars      on
    restricted_shell        off
    shift_verbose   off
    sourcepath      on
    xpg_echo        off

    User@hej ~
    $ set
    + set
    ALLUSERSPROFILE='C:\Documents and Settings\All Users'
    APPDATA='C:\Documents and Settings\User\Application Data'
    BASH=/bin/bash
    BASHOPTS=checkhash:checkwinsize:cmdhist:complete_fullquote:expand_aliases:extglob:extquote:force_fignore:histappend:histreedit:histverify:hostcomplete:interactive_comments:login_shell:no_empty_cmd_completion:nocaseglob:progcomp:promptvars:sourcepath
    BASH_ALIASES=()
    BASH_ARGC=()
    BASH_ARGV=()
    BASH_CMDS=()
    BASH_LINENO=()
    BASH_SOURCE=()
    BASH_VERSINFO=([0]="4" [1]="3" [2]="46" [3]="6" [4]="release" [5]="i686-pc-cygwin")
    BASH_VERSION='4.3.46(6)-release'
    CLIENTNAME=Console
    COLUMNS=132
    COMMONPROGRAMFILES='C:\Program Files\Common Files'
    COMPUTERNAME=HEJ
    COMSPEC='C:\WINDOWS\System32\CMD.EXE'
    CYGDRIVE=/cygdrive
    CYGWIN_HOME='C:\cygwin'
    CYG_SYS_BASHRC=1
    CommonAppData='C:\Documents and Settings\All Users\Application Data'
    CommonDesktop='C:\Documents and Settings\All Users\Desktop'
    CommonDocuments='C:\Documents and Settings\All Users\Documents'
    CommonFavorites='C:\Documents and Settings\All Users\Favorites'
    CommonMusic='C:\Documents and Settings\All Users\Documents\My Music'
    CommonPictures='C:\Documents and Settings\All Users\Documents\My Pictures'
    CommonTemplates='C:\Documents and Settings\All Users\Templates'
    CommonVideos='C:\Documents and Settings\All Users\Documents\My Videos'
    DIRSTACK=()
    DefaultUserProfile='C:\Documents and Settings\Default User'
    DevMgr_Show_Details='*'
    DevMgr_Show_NonPresent_Devices='*'
    EUID=197614
    EXECIGNORE='*.dll'
    FP_NO_HOST_CHECK=NO
    GNUGCC=/cygdrive/g/GNU-GCC
    GROUPS=()
    HISTFILE='/c/Documents and Settings/User/.bash_history'
    HISTFILESIZE=500
    HISTSIZE=500
    HOME=/cygdrive/g/GNU-GCC/home/User
    HOMEDRIVE=C:
    HOMEPATH='\Documents and Settings\User'
    HOSTNAME=hej
    HOSTTYPE=i686
    IFS=$' \t\n'
    IGNOREEOF=10
    INFOPATH=/usr/local/info:/usr/share/info:/usr/info
    JD2_HOME='C:\Documents and Settings\User\Local Settings\Application Data\JDownloader 2.0'
    LANG=en_US.UTF-8
    LESS=$'-i -w -s -z-4 -g -M -X -r -f -P%t?f%f \\\n:stdin .?pb%pb\\%:?lbLine %lb:?bbByte %bb:-...'
    LESSCHARSET=latin1
    LESSOPEN='|/usr/bin/lesspipe.sh %s 2>&-'
    LESS_TERMCAP_mb=$'\E[01;31m'
    LESS_TERMCAP_md=$'\E[01;31m'
    LESS_TERMCAP_me=$'\E[0m'
    LESS_TERMCAP_se=$'\E[0m'
    LESS_TERMCAP_so=$'\E[01;44;33m'
    LESS_TERMCAP_ue=$'\E[0m'
    LESS_TERMCAP_us=$'\E[01;32m'
    LINES=80
    LOGONSERVER='\\HEJ'
    MACHTYPE=i686-pc-cygwin
    MTPPKROOT='C:\WMSDK\MTPPK12\Responder'
    NUMBER_OF_PROCESSORS=2
    OLDPWD='/c/Documents and Settings/User'
    OPTERR=1
    OPTIND=1
    ORIGINAL_PATH='/usr/bin:/c:/c/tools:/c/WINDOWS/System32:/c/WINDOWS:/c/WINDOWS/System32/WBEM:/c/WINDOWS/system32/WindowsPowerShell/v1.0:/c/cgywin/bin:/c/MinGW/bin:/c/Documents and Settings/All Users/Application Data/Oracle/Java/javapath:/c/Program Files/rexx.org/Regina:/c/Program Files/rexx.org/THE'
    OS=Windows_NT
    OSTYPE=cygwin
    PAGER=less
    PATH='./://cygdrive/c/bin:/usr/local/bin:/usr/bin:/usr/bin:/c:/c/tools:/c/WINDOWS/System32:/c/WINDOWS:/c/WINDOWS/System32/WBEM:/c/WINDOWS/system32/WindowsPowerShell/v1.0:/c/cgywin/bin:/c/MinGW/bin:/c/Documents and Settings/All Users/Application Data/Oracle/Java/javapath:/c/Program Files/rexx.org/Regina:/c/Program Files/rexx.org/THE:/c/Documents and Settings/User'
    PATHEXT='.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.REX;.Rexx;.PSC1'
    PIPESTATUS=([0]="0")
    PPID=944
    PRINTER='HP LaserJet Professional P1606dn'
    PROCESSOR_ARCHITECTURE=x86
    PROCESSOR_IDENTIFIER='x86 Family 15 Model 6 Stepping 2, GenuineIntel'
    PROCESSOR_LEVEL=15
    PROCESSOR_REVISION=0602
    PROFILEREAD=true
    PROGRAMFILES='C:\Program Files'
    PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
    PS2='> '
    PS4='+ '
    PSModulePath='C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\'
    PWD=/cygdrive/g/GNU-GCC/home/User
    REGINA_HOME='C:\Program Files\rexx.org\Regina'
    REGINA_LANG=en
    REGINA_LANG_DIR='C:\Program Files\rexx.org\Regina'
    SESSIONNAME=Console
    SHELL=/bin/bash
    SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:ignoreeof:interactive-comments:monitor:noclobber:notify:nounset:xtrace
    SHLVL=1
    SYSTEMDRIVE=C:
    SYSTEMROOT='C:\WINDOWS'
    TEMP=/tmp
    TERM=xterm
    THE_HELP_FILE='C:\Program Files\rexx.org\THE\THE_Help.txt'
    THE_HOME_DIR='C:\Program Files\rexx.org\THE'
    THE_MACRO_PATH='C:\Program Files\rexx.org\THE\extras'
    TMP=/tmp
    TZ=America/New_York
    UID=197614
    USER=User
    USERDOMAIN=HEJ
    USERNAME=User
    USERPROFILE='C:\Documents and Settings\User'
    WINDIR='C:\WINDOWS'
    _=shopt
    _NT_SYMBOL_PATH='srv*c:\symbols*https://msdl.microsoft.com/download/symbols'
    profile_d ()
    {
        _LC_ALL_SET_="${LC_ALL+set}";
        _LC_SAVE_="${LC_ALL-null}";
        LC_ALL=C;
        if [ "${_LC_SAVE_}" = "null" ]; then
            for file in /etc/profile.d/*.$1;
            do
                [ -e "${file}" ] && . "${file}";
            done;
            unset LC_ALL;
        else
            for file in /etc/profile.d/*.$1;
            do
                [ -e "${file}" ] && LC_ALL="${_LC_SAVE_}" . "${file}";
            done;
            LC_ALL="${_LC_SAVE_}";
        fi;
        unset file;
        unset _LC_ALL_SET_;
        unset _LC_SAVE_
    }
    wcd ()
    {
        cd $(sed -e 's~\\~/~g' -e 's~c:~$CYGDRIVE/c~g' -e 's~g:~$CYGDRIVE/g~' <<< "$@")
    }

    User@hej ~
    $ mount
    + mount

Ctrl-c entered <------


    User@hej ~
    $

    User@hej ~
    $

    User@hej ~
    $ man mount
    + man mount
Ctrl-c entered <------


    User@hej ~
    $

DOSパス:

PATH=C:\cygwin\bin\;C:\;c:\tools;C:\WINDOWS\System32;C:\WINDOWS;C:\WINDOWS\System32\WBEM;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\cgywin\bin;C:\MinGW\bin;C:\Documents and Settings\All Users\Application Data\Oracle\Java\javapath;C:\Program Files\rexx.org\Regina;C:\Program Files\rexx.org\THE

答え1

次のように、ローカルボリュームのFSTABにエントリを追加してシステムを「破損」させました。

# /etc/fstab
#
#    This file is read once by the first process in a Cygwin process tree.
#    To pick up changes, restart all Cygwin processes.  For a description
#    see https://cygwin.com/cygwin-ug-net/using.html#mount-table

# This is default anyway:
none /cygdrive cygdrive binary,posix=0,user 0 0

c:/ /c ntfs text,posix=0 0 0
d:/ /d ntfs text,posix=0 0 0
f:/ /f ntfs text,posix=0 0 0
g:/ /g ntfs text,posix=0 0 0

fstabを次のように変更して「固定」しました。

none /cygdrive cygdrive binary,posix=0,user 0 0
none /tmp usertemp binary,posix=0 0 0

c:/  /c  ntfs binary,posix=0,cygexec 0 0
d:/  /d  ntfs binary,posix=0,cygexec 0 0
f:/  /f  ntfs binary,posix=0,cygexec 0 0
g:/  /g  ntfs binary,posix=0,cygexec 0 0

私が考えるために4つのドライブ(c、d、f、g)を「exec」としてマウントしないと、cygwinが外部から検索するたびに「魔法の」バイトを見つけるために複数のファイルを開いて読み取ることができます。ファイルが実行可能な場合。

一方、minttyは私がctrl-cを押して終了するまで、私の入力をTypeAheadにバッファリングして、私のコマンドに対して実行中の検索を終了します。

オプションに "cygexec"を追加すると、検索はディレクトリの実行可能フラグのみを参照し、最大速度で実行されます。

関連情報