3 ms·
This has bugged me for a long time too – on Linux you can use readlink -f to get realpath, but that’s not available on OS X. So I built it into Oils (both OSH
by chubot 3y ago
This has bugged me for a long time too – on Linux you can use readlink -f to get realpath, but that’s not available on OS X.
So I built it into Oils (both OSH and YSH):
source $_this_dir/lib/util.ysh
$_this_dir is a special variable that’s relative to the file it’s being sourced from.
https://www.oilshell.org/release/0.19.0/doc/ref/chap-special-var.html#_this_dir https://www.oilshell.org/release/0.19.0/doc/ref/chap-special...
https://www.oilshell.org/release/latest/doc/ysh-tour.html#appendix-example-of-an-ysh-module https://www.oilshell.org/release/latest/doc/ysh-tour.html#ap...
It starts with a _ to let you know it’s magic, similar to _status and _process_sub_status (the latter being unavailable in any shell besides Oils BTW)
So yeah this one reason I say POSIX and shell are “rotting” – they lack extremely basic functionality like this. This could have been done 20 years ago, but there’s nobody really pushing it.
(We may add namespaces to shell, which will change some things in the example above, but it won’t change _this_dir. We can use feedback and help! - See recent story https://lobste.rs/s/h4egaz/oils_winter_status_update https://lobste.rs/s/h4egaz/oils_winter_status_update )
(copy of lobste.rs comment - https://lobste.rs/s/4emmdl/sh_relative_shell_script_includes_with https://lobste.rs/s/4emmdl/sh_relative_shell_script_includes...)
more:
Oils Winter Status Update - https://www.oilshell.org/blog/2023/11/status-update.html https://www.oilshell.org/blog/2023/11/status-update.html