Skip to content

Conversation

@cD1rtX3
Copy link

@cD1rtX3 cD1rtX3 commented Dec 28, 2025

dev build for branch | USERNAME:BRANCHNAME

Added:

  • check against useless "$0",
  • export GTK_PREFIX=, and
  • shellcheck directives against warnings;

replaced printf with echo; redirected status messages to stderr; added -- safeguard for builtins when necessary; and removed exec.

Check if completed:

Added:

  * check against useless `"$0"`,
  * `export GTK_PREFIX=`, and
  * shellcheck directives against warnings;

redirected status messages to `stderr`; and removed `exec`.
@cD1rtX3
Copy link
Author

cD1rtX3 commented Dec 28, 2025

I complied with what seems to be the style guide, but that isn't the standard style guide (notably, the use of double-quotes instead of single-quotes and the quoted cases).

Copy link
Member

@YoshiRulz YoshiRulz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused by this PR. Did you just throw it into a linter and apply every suggestion?

*"EmuHawkMono.sh");;
*"/bin/"*"sh")
# Very bad way to detect /path/to/shell
echo "I don't know where I am! Could you run me as \"/path/to/EmuHawkMono.sh\"?"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should support being renamed via symlinking.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this now support something like ln -s /opt/bizhawk/EmuHawkMono.sh ~/.local/bin/emuhawk?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It will just think you're running it with a shell if that executable's name ends in sh, but not .sh. I don't know how else to better detect a shell, since bash for some reason uses its fullly-qualified path as "$0" when a script is sourced.

exec mono EmuHawk.exe "$@"
echo "(it seems EmuHawk is already running, NOT capturing output)" >& 2
mono EmuHawk.exe "$@"
return 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with exec? And at least return $?.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exec for a command is undefined behaviour in sh, which you're targeting. You are right about return "$?", though.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exec for a command is undefined behaviour in sh, which you're targeting.

Looks defined to me, and I couldn't find anyone proscribing against it. Which shell doesn't support it?

Copy link
Author

@cD1rtX3 cD1rtX3 Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh. I thought I'd read that in the publication somewhere. Oh well.

Also, that link leads to the main page, not the specific page you likely wanted.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it looks like exec will only look for non-builtins, though this behaviour can be mimicked by just using ./command. It seems you can replace what I did with exec -- # command if you want to.

"arch"|"artix"|"manjarolinux") libpath="/usr/lib";;
"fedora"|"gentoo"|"nobaralinux"|"opensuse") libpath="/usr/lib64";;
"nixos") libpath="/usr/lib"; printf "Running on NixOS? Why aren't you using the Nix expr?\n";;
"nixos") libpath="/usr/lib"; echo "Running on NixOS? Why aren't you using the Nix expr?" >& 2;;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an error, this codepath is theoretically supported, though I have no idea if it works.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'm in the habit of always using printf because of echo's footguns.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, it is not an error. However, status messages should always go to stderr, so not to conflate with actual output.

Copy link
Author

@cD1rtX3 cD1rtX3 Dec 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The footguns you mention only really happen with arbitrary variables. If one were to pass in -n from a variable, echo would get confused. However, when printing a simple string, it's better to use the simplest method.

@YoshiRulz YoshiRulz added the Meta Relating to code organisation or to things that aren't code label Dec 28, 2025
@cD1rtX3
Copy link
Author

cD1rtX3 commented Dec 28, 2025

No, I didn't "just throw it into a linter", though I do have a linter in my IDE. I noticed some minor issues, and thought the simplest way to get them fixed was to simply open a PR.

@YoshiRulz
Copy link
Member

What's this style guide you're referring to?

@cD1rtX3
Copy link
Author

cD1rtX3 commented Dec 29, 2025

I guess there isn't a strict “standard style guide”, just “what you'll generally see code written like online/in books”, thus being what more people are used to. If you mean your style guide, it's what I inferred from how you wrote the code in that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Meta Relating to code organisation or to things that aren't code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants