opm-simulators icon indicating copy to clipboard operation
opm-simulators copied to clipboard

--output-dir=~/subdir is not correctly expanded

Open blattms opened this issue 2 years ago • 3 comments

simulator puts the output file into a subdirectory ./~/subdir of the current directory

blattms avatar Dec 14 '23 10:12 blattms

simulator puts the output file into a subdirectory ./~/subdir of the current directory

Right. For what it's worth, I don't think we've ever claimed to support tilde expansion in directory names, but it would clearly be "nice" to do so.

bska avatar Dec 14 '23 11:12 bska

I must admit I never tried, but I would assume that tilde expansion of command line arguments is done by the shell, not the user program?

atgeirr avatar Dec 14 '23 11:12 atgeirr

but I would assume that tilde expansion of command line arguments is done by the shell, not the user program?

That's generally true, yes, and I do agree that it's probably a shell problem here. The only reason I'm not completely convinced is an interaction between our parameter system and the shell here. When the user sets --output-dir=~/x, we end up in the base vanguard's callImplementationInit() function at which point the GET_PARAM() macro probably generates the unexpanded string ~/x. I'd have to look at the full details of the shell's tilde expansion for why we might not get expansion in the case of the command line argument.

On the other hand, if the user specifies a parameter file with

OutputDir="~/x"

then there'd be no choice but to expand the tilde ourselves.

We should probably think hard about whether we want to allow that, though, because it's quite common, especially on servers, for there not to be a valid ${HOME} entry in the environment. I stubbed out a hacky, Posix-only, function for computing the login process's "home" directory independently of the environment, but that's not something I'd like to add to Opm.

bska avatar Dec 14 '23 18:12 bska