Skip to content

Search $PATH on Unix - #5

Open
Grissess wants to merge 3 commits into
bill2009:masterfrom
Grissess:master
Open

Search $PATH on Unix#5
Grissess wants to merge 3 commits into
bill2009:masterfrom
Grissess:master

Conversation

@Grissess

Copy link
Copy Markdown

See the commit messages for further details. In summary, though, these changes should make it much easier to build a portable version of this software, while not sacrificing the ability to compile-in certain paths if need be. The ergonomics on Linux for local administrators is thereby much improved.

execvp searches a user's $PATH, allowing for the specification of
relative paths, which this commit uses by default. This is particularly
convenient for users and administrators who wish to set up portable
installations or have systems with mercurial filesystem layouts.

In introducing this change, the path for `asl` is no longer hard-coded
to `/usr/bin/asl`; instead a macro `ASEXE` can be provided. Since its
invocations also use execvp, it can be anywhere on $PATH, and thus
`ASEXE` defaults to the empty string.
It seems that the Qt Resource Compiler has decided to use `rcc`; as per
the [FHS 3.0][FHS], Debian unpackages this into `/usr/bin` as the
"primary directory" for "most commands" without regard to other
mountpoints (cf. /bin). `/usr/local` is set aside for "software locally
installed" that is "safe from being overwritten when system software is
updated", and is a reasonable choice for unpackaged software such as
this.

Without citation, most Linux hosts I've seen order their PATHs as
`/usr/local/{sbin,bin}`, then `/usr/{sbin,bin}`, then `/{sbin,bin}`,
which means that `/usr/local` will have higher search precedence, making
it particularly suitable for the execvp changes introduced in 4998f38,
while making conflicting binaries (i.e. Qt's `rcc`) still accessible by
absolute path (e.g. `/usr/bin/rcc`) if needed.

[FHS]: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
@Grissess

Copy link
Copy Markdown
Author

The next commit is fine, IMO, to cherry-pick out, but is (1) a tiny change and (2) pursuant with the goals of making this ergonomic on Unix, where file names are entirely case-sensitive.

The code emitted by this generator was incapable of being assembled on
systems with case-sensitive filesystems.
@bill2009

bill2009 commented Aug 19, 2023 via email

Copy link
Copy Markdown
Owner

@Grissess

Copy link
Copy Markdown
Author

Hi: I'm fine with the changes if they still fit the build instructions at: bill2009/lcc1802: An ANSI C Compiler for the RCA 1802 family of processors (github.com)https://github.com/bill2009/lcc1802#installing-for-linux

Commit 750c6d0 does change those instructions, but they remain largely the same--the only difference is recommending /usr/local/bin as the install target (since it usually takes precedence in $PATH). Because of the $PATH search, even doing it "the old way" should work out unless there's a name conflict (Qt's rcc comes to mind), which is why the change to use a preemptive priority in the search path was proposed. In particular, the executables no longer depend on hard-coded paths by default, but you can still have your cake and eat it too if you need the feature :)

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

Successfully merging this pull request may close these issues.

2 participants