jgabaut / amboso

Build tool wrapping make. Written in bash.
GNU General Public License v3.0
4 stars 0 forks source link

[BUG] Script hangs when awk is nawk #100

Closed AliShahabzadeh closed 7 months ago

AliShahabzadeh commented 7 months ago

https://github.com/jgabaut/amboso/blob/9d68d2fb3e80a4bbb17b35a4b0b269c827904d1c/amboso_fn.sh#L1767

The program fails to proceed beyond this point on MacOS M1.

jgabaut commented 7 months ago

Darn, I was really hoping we could leave #58 behind. Sigh...

Let's look into this.

Can you remove the stderr suppression and see if it does anything? Delete 2>/dev/null and retry your check to ensure execution stops at that precise line.

These are set near the start of amboso_parse_args():

AliShahabzadeh commented 7 months ago

After removing the specified portion and executing the program, the subsequent line appeared in the output.

awk: unknown option -W ignored
jgabaut commented 7 months ago

That's a burn. I expected to be able to use -W to detect the actual version of the program symlinked to awk on a system, to differenciate between a full awk (we need some extensions) and mawk. If you look at this issue:

Near the bottom it says a version of mawk which was on another machine and also had problems. Can you try something like:

AliShahabzadeh commented 7 months ago

When attempting the commands on a Mac M1, I observed that executing awk --help, awk --h, and awk -H did not yield any response. However, awk --version provided the output:

awk version 20200816
jgabaut commented 7 months ago

I'll try to look into this soon, I'm halfway through the release of invil 0.2.7 which ports the changes of 2.0.3. Should provide a patch for this and the included najlo bugs (see #99) in a couple of days.

Can you provide any more context about the problem? In particular:

I guess the "fix" is gonna end up being just checking for gawk directly and bailing when it's missing.

jgabaut commented 7 months ago

Apparently, the awk version provided by macOS only supports --version, while mawk only supports -W version.

See here for reference:

The current check should be fixed and a correct guess should be made. I guess calling gawk directly may also work... I'll see.

AliShahabzadeh commented 7 months ago

Upon reviewing various developers' experiences, it became apparent to me that they resolved the issue by installing gawk. However, I remain uncertain whether MacOS utilizes a customized iteration of mawk under the guise of awk or employs an alternative version known as nawk.

jgabaut commented 7 months ago

@AliShahabzadeh We came to the same conclusion. Let me make some clarity:

I updated the title to better distinguish this issue from the other, even though they come out of the same code section, since they have different reasons and a proper fix would necessarily mean handling both nawk and mawk properly. Hanging is not an option.

On a side note, I'm still confused at why the line mentioned in the first post (1767) just hangs. A guess:

I'm not really sure if that's what's happening.

Now, onto fixing our issue:

Relying solely on the output grepping was a bad idea from the start, but for now we can just make the check sane (by trying both kind of version flags, checking the results of the command, and resolving which awk we have).

I would start working on this in a few days, but if you want to have a stab at it, please fork and branch with any changes you'd like to contribute. In any case, I should be able to chop this when I have a little time, it's not too hard.

jgabaut commented 7 months ago

@AliShahabzadeh my tests seem to show that the revised check in 2.0.4 should correctly pick up the needed gawk implementation for awk. Furthermore, I updated the README to better show that we actually need it.

Let me know if the new patch fixed your problem. Closed with the PR, for now.