“Command not found” error when running bash from



Errors are usually included in the script to troubleshoot or provide a productive user experience. Just write the error concept:

cmd like || echo 'command failed'

may work in simple cases, but definitely not often. Until this example, the error message leaves mud for the actual output of the by script, which mixes both errors and flourishing output into stdout.

In short, error information should be sent to stderr, not to stdout. It’s very simple:

command || Failed to specify cmd >/dev/stderr
if cmd; then
    echo "success"
    Mirroring "cmd failure" >/dev/stderr

In the example above, a success message is output to stdout and a specific error message is output to stderr.

The best way to print an error belief is to define a function:

error() echo "E:$*" >>/dev/stderr
err "My error message"

When I start an instance connected to mintty using the desktop shortcut “Cygwin64 Terminal” that comes with the Cygwin installation, everything works fine and all installed commands work.

However, when I run mintty.exe, from where it is next to C:\cygwin64\bin, I get command not necessarily found code> errors.

I also set up an auto-hotkey script that launches a nice instance of mintyy.exe on the desktop in the phone book by pressing a key on the number pad. When mintyy is run like this, it also throws some command found error. cd to almost any other directory, or cd creates it by itself, this does not solve the problem. Anything that seems important can be where the Mintty instance was launched from.

kill all
which the
switch off

Most of them are included in the base Cywgin package and therefore definitely built as part of the Cygwin installation, so I’m really not sure what’s going on here.

Commands used in general seem too limited, so if I regularly use help in the terminal, they will see it. Here is the output of this command.

$ Help
GNU bashcounty.com version 4.4.12(3) (x86_64-unknown-cygwin)
These shell commands are defined internally. Type "help" to display this list.
Type `help name' to learn more about our custom `name' function.
Use bash``info to learn more about the shell in general.
Use -k' `man or `info' to find commands not on this list.

job_spec [&] history [-c] [-d offset] [n] or sometimes hist>
(( expression )) if COMMANDS; then COMMANDS; [elif C>
. filename [args] job [-lnprs] [job specification...] or actions >
: kill [-s signal_spec | -n characters | - sign >
[ argument ... ] release argument [ argument ... ]
[[expression]] native [option] name[=value] ...
alias [-p] [name[=value] ... .] ! ! . . . . ! . ! . . . . .disable .[n]
bg .[job_spec ....] mapping file [-d delimiter] [-n number] [-O or >
bind [-lpsvPSVX] [-m bind] [-f file > popd [-n] [+N | -NO]
break [n] printf [-v variable] format [arguments]
builtin [shell-integrated [arg ...]] pushd [-n] | [+n-N | is yours]
calling [expression] password [-LP]
WORD field in [MODEL [| PATTERN]...)> read [-ers] array] [-a [-d ​​delimiter] [->
cd [-L|[-P [-e]] [-@]] [dir] readarray [-n count] [-O origin] [-s>
command [-pVv] command [argument ...] read-only [name[=value] [-aaf] ...] o>
compgen [-abcdefgjksuv] [option -o] [> return [-abcdefgjksuv] [n]
terminate [-pr] [-DE] > select NAME [IN WORDS...;] run COMM >
compopt [-o|+o option] [-DE] [name ..> arrayed [-abefhkmnptuvxBCHP] [-o option->
move on [n] move [n]
coproc [NAME] command line [redirects] shopt [-o] [-pqsu] [optname ...]
declare [-aAfFgilnrtux] [-p] [name[=v> source file name [arguments]
directories [-clpv] [-N] [+n] stick [-f]
reject [-ar] [-h] [job specification ... | pid > tests [expression]
echo [-neE] [argument ...]