scandum / tintin

TinTin++, aka tt++, is an extensible console MUD client.
https://tintin.mudhalla.net
GNU General Public License v3.0
201 stars 56 forks source link

Substitute "~" for home directory in #READ command #15

Closed prg318 closed 4 years ago

prg318 commented 4 years ago

Hello!

It would be helpful to be able to reference a user's home directory to make it easier to load scripts inside of a script. For example, a user could do something like this without having to hardcode a specific home directory:

#read ~/.config/tintin/movement.tintin
#read ~/.config/tintin/logging.tintin

I've made a very rudimentary patch that performs a substitution in file.c before the file is read: https://github.com/scandum/tintin/compare/master...prg318:expand-tilde I didn't submit this as a PR because I doubt this is the most elegant solution, but it seems to work OK as a patch.

scandum commented 4 years ago

Hi,

It's possible to use

#info system save
#var home $info[SYSTEM][HOME]

#read $home/.config/tintin/movement.tintin

Might be an option if you don't care about the extra verbosity. Adding ~ support is on my todo list, it will indeed be a more involved solution.