diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 70718735b..98d309738 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2479,6 +2479,8 @@ Unix: add ../include/nhlua.h to the alloc.o dependencies in Makefile.utl to Unix: implement SELF_RECOVER compile-time option, on by default on linux Unix: allow build to succeed with musl (instead of glibc), by specifying musl=1 on the make command line +Unix: support tilde expansion for home directory path, "~/relative-path", in + command line --nethackrc=path and environment NETHACKOPTIONS=@path user_sounds: move the message hook from inside individual window display ports to the core where it allows MSGTYP_NOSHOW msgtyp's to still trigger sounds to correct a reported github issue; also fixes a past reported diff --git a/src/cfgfiles.c b/src/cfgfiles.c index 3a3c0ff06..ca05d35cd 100644 --- a/src/cfgfiles.c +++ b/src/cfgfiles.c @@ -242,6 +242,13 @@ fopen_config_file(const char *filename, int src) if (filename && *filename) { set_configfile_name(filename); #ifdef UNIX + if (!strncmp(configfile, "~/", 2) && (envp = nh_getenv("HOME")) != 0) { + /* support for command line '--nethackrc=~/path' (or for + NETHACKOPTIONS='@~/path'; we don't support ~user/path) */ + Snprintf(tmp_config, sizeof tmp_config, "%s/%s", + envp, configfile + 2); /* insert $HOME/ and remove ~/ */ + set_configfile_name(tmp_config); + } if (access(configfile, 4) == -1) { /* 4 is R_OK on newer systems */ /* nasty sneaky attempt to read file through * NetHack's setuid permissions -- this is the only