public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* exe in path directory, "command not found"
@ 2023-03-15  3:00 WyntrHeart
  2023-03-15  3:07 ` Eliot Moss
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: WyntrHeart @ 2023-03-15  3:00 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 406 bytes --]

I've added /cygdrive/c/program\ files/notepad++ to my path in .bash_profile, double checking with echo to make sure that the directory is in the path. But when I type "notepad++.exe" or "notepad++" I get "bash: notepad++: command not found". I did restart the terminal before testing to make sure that .bash_profile was loaded and path was updated. Is there something I'm doing wrong here or is this a bug?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exe in path directory, "command not found"
  2023-03-15  3:00 exe in path directory, "command not found" WyntrHeart
@ 2023-03-15  3:07 ` Eliot Moss
  2023-03-15  3:27 ` René Berber
  2023-03-15  7:27 ` Sam Edge
  2 siblings, 0 replies; 5+ messages in thread
From: Eliot Moss @ 2023-03-15  3:07 UTC (permalink / raw)
  To: WyntrHeart, cygwin

On 3/14/2023 11:00 PM, WyntrHeart via Cygwin wrote:
> I've added /cygdrive/c/program\ files/notepad++ to my path in .bash_profile, double checking with echo to make sure that the directory is in the path. But when I type "notepad++.exe" or "notepad++" I get "bash: notepad++: command not found". I did restart the terminal before testing to make sure that .bash_profile was loaded and path was updated. Is there something I'm doing wrong here or is this a bug?

That would be:  /cygdrive/c/Program\ Files/notepad++  -- assuming that's a *folder*
that contains notepad++.exe ...

Note that path (written PATH, and generally exported) contains folder names separated by colons.

To add to the end you can do:

export PATH="$PATH:/cygdrive/c/Program Files/notepad++"

Note: no \ in front of space inside the quotes.

Best - Eliot Moss

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exe in path directory, "command not found"
  2023-03-15  3:00 exe in path directory, "command not found" WyntrHeart
  2023-03-15  3:07 ` Eliot Moss
@ 2023-03-15  3:27 ` René Berber
  2023-03-15  3:27   ` René Berber
  2023-03-15  7:27 ` Sam Edge
  2 siblings, 1 reply; 5+ messages in thread
From: René Berber @ 2023-03-15  3:27 UTC (permalink / raw)
  To: cygwin

On 3/14/2023 9:00 PM, WyntrHeart via Cygwin wrote:

> I've added /cygdrive/c/program\ files/notepad++ 

Notepad is not there.

In addition to what Elliot said you need the correct path.

The executable is at: /cygdrive/c/Program Files/Notepad++/notepad++

So the path is all that except the .exe name.
-- 
R.B.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exe in path directory, "command not found"
  2023-03-15  3:27 ` René Berber
@ 2023-03-15  3:27   ` René Berber
  0 siblings, 0 replies; 5+ messages in thread
From: René Berber @ 2023-03-15  3:27 UTC (permalink / raw)
  To: cygwin

On 3/14/2023 9:00 PM, WyntrHeart via Cygwin wrote:

> I've added /cygdrive/c/program\ files/notepad++ 

Notepad is not there.

In addition to what Elliot said you need the correct path.

The executable is at: /cygdrive/c/Program Files/Notepad++/notepad++

So the path is all that except the .exe name.
-- 
R.B.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: exe in path directory, "command not found"
  2023-03-15  3:00 exe in path directory, "command not found" WyntrHeart
  2023-03-15  3:07 ` Eliot Moss
  2023-03-15  3:27 ` René Berber
@ 2023-03-15  7:27 ` Sam Edge
  2 siblings, 0 replies; 5+ messages in thread
From: Sam Edge @ 2023-03-15  7:27 UTC (permalink / raw)
  To: cygwin


[-- Attachment #1.1.1: Type: text/plain, Size: 1122 bytes --]

On 15/03/2023 03:00, WyntrHeart via Cygwin wrote:
> I've added /cygdrive/c/program\ files/notepad++ to my path in .bash_profile,
> double checking with echo to make sure that the directory is in the path. But
> when I type "notepad++.exe" or "notepad++" I get "bash: notepad++: command
> not found". I did restart the terminal before testing to make sure that
> .bash_profile was loaded and path was updated. Is there something I'm doing
> wrong here or is this a bug?
>

As per René & Eliot but anyone who uses Notepad++ a lot from Cygwin might be
interested in the attached script which can be put in /etc/profile.d/ or
sourced from your .bashrc. It creates a shell function 'npp' that parses the
command line and translates pathnames to Windows format before passing to
Notepad++. It adds a --wait argument to cause the caller to wait on Notepad++
instance exiting before returning.

The second script ('npp') provides a wrapper around the first for POSIX programs
looking for an executable e.g. git commit message editor etc.

I've done the same for kdiff3 if anyone wants them.

--
Sam Edge


[-- Attachment #1.1.2: zzzz_91.npp.sh --]
[-- Type: text/plain, Size: 3751 bytes --]

#!/bin/bash
#
# Script to add an "npp" function to invoke Notepad++ to a bash shell session.
#
# $Id: zzzz_91.npp.sh 446 2020-12-21 14:05:26Z samedge $
#

# Uses bash-specific extensions.
[ "x${BASH_VERSION}" = "x"  ] && return 0

function npp {

    [[ -z "${SSH_CLIENT-}" ]] || { echo 'Appear to be running via secure shell - cannot launch Windows GUI executables.' 1>&2 ; return 255 ; }
    if [[ -n "${DISPLAY-}" ]] ; then
        local -r display_host="${DISPLAY%:*}"
        if [[ -n "$display_host" && "$display_host" != "localhost" && "$display_host" != "127.0.0.1" ]] ; then
            { echo 'Appear to be running from a remote X client - cannot launch Windows GUI executables.' 1>&2 ; return 255 ; }
        fi
    fi

    local exe=
    if test -v _NOTEPAD_PLUS_PLUS_EXE && [ -x "$_NOTEPAD_PLUS_PLUS_EXE" ] ; then
        exe="$_NOTEPAD_PLUS_PLUS_EXE"
    else
        local -a path=()
        test -v PROGRAMFILES && path+=("$PROGRAMFILES")
        test -v ProgramW6432 && path+=("$ProgramW6432")
        path+=("$(cygpath --windows -F 42)") # :NOTE: Work-around for parsing "ProgramFiles(x86)" as a variable name - bash chokes!
        path+=('C:\Program Files')
        path+=('C:\Program Files (x86)')

        local dir
        for dir in "${path[@]}"
        do
            if [[ -n "$dir" ]] ; then
                local candidate
                candidate="$(cygpath --unix --absolute -- "$dir")/Notepad++/notepad++"
                #candidate="$dir\\Notepad++\\notepad++.exe"
                if [ -x "$candidate" ] ; then
                    exe="$candidate"
                    break
                fi
            fi
        done
        [[ -n "$exe" ]] || { echo 'Cannot find Notepad++ Windows executable.' 1>&2 ; return 255 ; }

        export _NOTEPAD_PLUS_PLUS_EXE="$exe"
    fi

    local -i dry_run=0
    local -i next_is_not_filename=0
    local -i next_is_optarg=0
    local wait=
    local -a argv=()

    local arg
    for arg in "$@"
    do
        if [[ "${arg:0:1}" == '-' ]] && (( ! next_is_optarg )) ; then
            case "$arg" in
                --dry-run )
                    arg=
                    dry_run=1
                    next_is_not_filename=0
                    next_is_optarg=0
                    ;;
                --wait )
                    wait="--wait"
                    arg="-multiInst"
                    next_is_not_filename=0
                    next_is_optarg=0
                    ;;
                --help | -multiInst | -noPlugin | -nosession | -notabbar | -ro | -systemtray | -loadingTime | -alwaysOnTop | -openSession | -r | -quickPrint )
                    next_is_not_filename=0
                    next_is_optarg=0
                    ;;
                -l* | -L* | -n* | -c* | -p* | -x* | -y* | -qn* | -qt* | -qSpeed* )
                    next_is_not_filename=0
                    next_is_optarg=0
                    ;;
                -qf* )
                    next_is_not_filename=0
                    next_is_optarg=0
                    arg="-qf$(cygpath --windows --absolute -- "$(realpath "${arg:3}")")" || return $?
                    ;;
                * )
                    next_is_not_filename=0
                    next_is_optarg=0
                    ;;
            esac
        else
            if (( ! next_is_not_filename )) ; then
                arg="$(cygpath --windows --absolute -- "$(realpath "$arg")")" || return $?
            fi
            next_is_not_filename=0
            next_is_optarg=0
        fi

        [ -n "$arg" ] && argv+=("\"$arg\"")
    done
    local -r -i argc="${#argv[@]}"

    (( dry_run )) ||
    if (( argc != 0 )) ; then
        cygstart $wait "$exe" "${argv[@]}"
    else
        cygstart $wait "$exe"
    fi
}

[-- Attachment #1.1.3: npp --]
[-- Type: text/plain, Size: 782 bytes --]

#!/bin/bash
#
# Generic wrapper for bash functions so they can be invoked by external tools.
# If the wrapper filename (or symlink) ends in 'w' then this is stripped and
# the function is invoked with the --wait option before any command line ones.
#
# The function definition must be in a file in /etc/profile.d/ of the form
# *.CMD.sh when CMD is the symlink filename without any trailing 'w' character.
#
# $Id: npp 222 2020-03-24 15:13:00Z SamEdge $
#

set -u
set -e
set -o pipefail

wait=
declare cmdname="$0"
cmdname="${cmdname##*/}"
if [[ "${cmdname: -1}" == 'w' ]] ; then
    cmdname="${cmdname::-1}"
    wait="--wait"
fi

. /etc/profile.d/*."$cmdname".sh

declare -r -i argcount="${#@}"

if (( argcount != 0 )) ; then
    "$cmdname" $wait "$@"
else
    "$cmdname" $wait
fi

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-15  7:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-15  3:00 exe in path directory, "command not found" WyntrHeart
2023-03-15  3:07 ` Eliot Moss
2023-03-15  3:27 ` René Berber
2023-03-15  3:27   ` René Berber
2023-03-15  7:27 ` Sam Edge

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).