I have a program that stores its settings in ~/.config/myprogram
that I use both interactively and with a batch queuing system. When running interactively, I want this program to use my configuration files (and it does). But when running in batch mode, the configuration files aren't necessary because I specify command-line options that overwrite all the relevant settings. Further, accessing the configuration files over the network increases the program's startup time by several seconds; if the files don't exist, the program launches much faster (as each job only takes about a minute, this has a significant impact on batch job throughput). But because I also use the program interactively, I don't want to be moving/deleting my configuration files all the time. Depending on when my batch jobs get scheduled on the cluster (based on other users' usage), I may want to use the program interactively and as part of a batch job at the same time.
(Aside: that network file performance is so slow is probably a bug, but I'm just a user of the cluster, so I can only work around it, not fix it.)
I could build a version of the program that doesn't read the configuration files (or has a command-line option not to) for batch use, but this program's build environment is poorly-engineered and difficult to set up. I'd much prefer to use the binaries installed through my system's package manager.
How can I trick particular instances of this program into pretending my configuration files don't exist (without modifying the program)? I'm hoping for a wrapper of the form pretendfiledoesntexist ~/.config/myprogram -- myprogram --various-options...
, but I'm open to other solutions.
apt-get source fceux; apt-get build-deps fceux
– derobert Jun 26 '14 at 20:37script -i
just runs the program andscript -b
first renames the config file. – psimon Jun 26 '14 at 20:39LD_PRELOAD
hook. That's easier (you can implement that in an hour or two, if you know C) than the alternative, which isptrace
. You could also probably use fakechroot to do this (which is LD_PRELOAD, I believe). – derobert Jun 26 '14 at 20:42open
, even. – derobert Jun 26 '14 at 20:44