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

sub/gsub/gensub function of awk/gawk not works properly in FISH #3515

Closed
1 of 2 tasks
frankyan opened this issue Oct 31, 2016 · 3 comments
Closed
1 of 2 tasks

sub/gsub/gensub function of awk/gawk not works properly in FISH #3515

frankyan opened this issue Oct 31, 2016 · 3 comments
Labels

Comments

@frankyan
Copy link

frankyan commented Oct 31, 2016

  • Have you checked if problem occurs with fish 2.3.1?
  • Tried fish without third-party customizations (check sh -c 'env HOME=$(mktemp -d) fish')?

fish version installed (2.3.1):

OS/terminal used:
Ubuntu 16.04 server

Talk about the the issue here.
awk or gawk sub function not works properly. The results are different from awk in bash.

Reproduction steps

In fish, use following command, it gave nothing.

gawk 'BEGIN{a = "abc def"; b = gensub(/(.+) (.+)/, "\\2 \\1", "g", a); print b}'

In bash, the same command gave the right output def abc

@faho
Copy link
Member

faho commented Oct 31, 2016

The issue here is the "" in quotes. Fish will still strip one of the two, while bash will leave it. See for yourself with e.g. echo gawk ....

Add one more - "\\\2 \\\1" and it works.

I think that this is expected (there are other differences in quoting behavior, and often with good reason), but I'll have to consult our docs some more.

@faho
Copy link
Member

faho commented Oct 31, 2016

Also, what does this have to do with math?

@frankyan
Copy link
Author

@faho Thank you! It works!
Sorry for the confusion of math which comes from the issue template.

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

No branches or pull requests

2 participants