Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'awk' is not recognized #330

Closed
span opened this issue Nov 27, 2014 · 9 comments
Closed

'awk' is not recognized #330

span opened this issue Nov 27, 2014 · 9 comments

Comments

@span
Copy link

span commented Nov 27, 2014

I saw this issue #23 which mentions that awk is not running. The issue is closed but since awk was not the main concern in the issue it was never treated.

I'm running Windows 7 64-bit and I have the awk binary in vendor\msysgit\bin\ but when I try to run it in Cmder it is not recognized

λ awk
'awk' is not recognized as an internal or external command,
operable program or batch file.

I changed the filename to awk.exe and got this instead:

λ awk
This version of [my path]\vendor\msysgit\bin\awk.exe is not compatible 
with the version of Windows you're running. Check your computer's system 
information to see whether you need a x86 (32-bit) or x64 (64-bit) version of 
the program, and then contact the software publisher.

I'm not sure if this is supposed to work or not but I figured I'd post it here if you have any input or for anyone else looking for this.

@rmorrin
Copy link
Contributor

rmorrin commented Nov 28, 2014

Interestingly, if we look at the contents of awk, it looks to be just a shell script that calls gawk.exe which (at least for me) works fine:

λ cat "C:\Program Files (x86)\Git\bin\awk"

#!/bin/sh
# Copyright (C) 2002, Earnie Boyd
#   mailto:earnie@users.sf.net
# This file is part of MSYS
#   http://www.mingw.org/msys.shtml
# File: awk

gawk "$@"

Using sh awk does work on my end.

@span
Copy link
Author

span commented Nov 28, 2014

Nice, I didn't take the time to investigate further and simply assumed awk was a binary. Running it as you say with sh awk seems to work fine.

λ sh awk
Usage: gawk [POSIX or GNU style options] -f progfile [--] file ...
        gawk [POSIX or GNU style options] [--] 'program' file ...
POSIX options:          GNU long options:
        -f progfile             --file=progfile
        -F fs                   --field-separator=fs
        -v var=val              --assign=var=val
        -m[fr] val
        -W compat               --compat
        -W copyleft             --copyleft
        -W copyright            --copyright
        -W help                 --help
        -W lint                 --lint
        -W lint-old             --lint-old
        -W posix                --posix
        -W re-interval          --re-interval
        -W source=program-text  --source=program-text
        -W traditional          --traditional
        -W usage                --usage
        -W version              --version

Report bugs to bug-gnu-utils@gnu.org,
with a Cc: to arnold@gnu.org

@rmorrin
Copy link
Contributor

rmorrin commented Nov 28, 2014

@span It's a strange one. Seems cmd.exe can't interpret how to run those files. Running awk from Git's included bash prompt works fine. The same is true with egrep which is just a wrapper for grep -E

For the time being, you can get around the issue by adding the following to cmder's aliases file

awk=sh awk $*

Admittedly not the most elegant solution, but easier than retraining your brain your brain to type sh awk every time :-)

@span
Copy link
Author

span commented Nov 28, 2014

Nice, I find working workarounds the most beautiful so I have no second thoughts about this ;)

@cyrusdavid
Copy link

I just added a new startup task with this command instead of an alias:

F:\ProgramFiles\CMDer\vendor\msysgit\bin\sh.exe --login -i -new_console:d:%USERPROFILE%

But I don't know how to get that cute lambda prompt.

@rmorrin
Copy link
Contributor

rmorrin commented Jan 20, 2015

@vohof Interesting, what are the benefits of using a startup task over an alias?

@cyrusdavid
Copy link

@rmorrin I could use all the other msysgit binaries

@valueforvalue
Copy link

A simple solution to this issue that works for Vista on up is just to use a symlink.

mklink awk.exe gawk.exe

Or you could create a batch file named awk.bat with the command:

@echo off
gawk %*

Do note that I'm not sure how the arguments are passed as far as spaces go. Wrapping the "%*" in quotes doesn't work. So I think the cleanest solution is just to use a symlink.

@jasperandrew
Copy link

I just renamed gawk.exe to awk.exe, and then the awk command worked fine. I don't know whether or not that's stable or normal, though...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants