0

I installed Cygwin to compile and run C programs. I'm trying to write my own shell program using Notepad++ as my editor. When I execute the compiled .exe file from the command line (using nppexec) it runs outside the Cygwin environment.
The following redirect command won't run with Window's cmd:

$ sort -r < test3.txt
-rThe system cannot find the file specified.

But works when the program is executed through Cygwin's Mintty:

$ sort -r < test3.txt
test3.txt
test.txt
sh.exe
sh.c
1.txt

I'm using the following code to run with nppexec to launch the program:

cd $(CURRENT_DIRECTORY)

gcc "$(FILE_NAME)" -o $(NAME_PART).exe

cmd.exe /c start cmd /k $(NAME_PART).exe

How do I edit the above to launch in the Cygwin Environment?
I've tried with no luck:

cmd /c start mintty ./$(NAME_PART).exe
George
  • 2,820
  • 4
  • 29
  • 56

1 Answers1

0

The Windows command line have it's own sort command, that behaves differently than the variant available through the Cygwin command line.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • @George I don't remember if `sort` is a built-in command or an external program. If it's an external program you could change your system `PATH` settings to put Cygwins `bin` path before the Windows system directories. However, that might cause other problems when the rest of the Windows world expects the standard Windows commands. – Some programmer dude Sep 11 '15 at 14:19
  • 1
    @George You can create a copy of the cygwin sort command, call it e.g. gsort (for gnu sort) then use gsort in your script. This way it does not interfere with the rest of the windows world. – Lars Fischer Sep 13 '15 at 14:41