1

I have Cygwin installed somewhere in the path. So I have

>where dir
D:\Users\Dims\Design\Cygwin64\bin\dir.exe

When I run DIR from CMD I get the normal Windows DIR:

>dir /?
Displays a list of files and subdirectories in a directory.

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]
  [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

...

But if I run it from under FAR, it takes DIR from Cygwin:

>dir /?
/usr/bin/dir: cannot access /?: No such file or directory

So, FAR is somehow ignoring precedence of built-in Windows commands. Is it possible to re-enable it?

2
  • 1
    What's your path env variable?
    – codaamok
    Commented Oct 6, 2016 at 9:59
  • 1
    The dir you want to run is an internal command only available from Windows cmd
    – DavidPostill
    Commented Oct 6, 2016 at 12:35

2 Answers 2

1

dir is an internal command of cmd.exe, hence you can't run it in any other shells including Windows PowerShell. There's no separate dir.exe

C:\>where dir
INFO: Could not find files for the given pattern(s).

There's no such thing like "Windows dir" or "built-in Windows commands". In PowerShell dir and ls are aliases of Get-ChildItem so you'll get an output like this instead of cmd's dir command output

PS C:\> dir


    Directory: C:\


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r---        3/28/2017  10:13 AM                Program Files
d-r---        3/28/2017  10:13 AM                Program Files (x86)
d-r---         1/3/2017   3:04 PM                User
d-----         4/5/2017  11:14 AM                Windows
               4/5/2017   2:55 PM           8192 ntuser.dat
-a----         4/7/2017   9:45 AM            152 useragent.log

The closest (and only way) you could come is calling cmd itself

cmd /c dir

or cmd /k dir if you want the cmd shell to remain.

0

In unix you can put a space before a command to ignore any alias of that command that is set up. If such a thing exists in Windows command prompt, I don't know what it is. I think that's what you're really asking.

The closest fix I can find is to use the & command separator. For example, ECHO & DIR will run the normal DIR command, but it will print ECHO is ON. first. I can't think of any DOS command that has no output.

But if you're running into this problem, you probably have a test.exe command in the cygwin/msys/git bash bin directory, which has no output, so you can get around it with test & dir.

Or, of course, you could make an empty batch file to put on the left side of the & separator.

Edit: Actually, I was playing around and DIR & ; works and doesn't require any external command.

Edit 2: The command in parentheses (DIR) works. Maybe that's the shortest thing.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .