Closed ihar-orca closed 2 years ago
FYI @alecthomas given https://github.com/mvdan/sh/pull/799.
Out of curiosity, what are you using the interpreter for? I assume you want some form of sandboxing, given this PR? :)
@mvdan in general, yes. I have a couple of shell scripts that run on a target Linux machine. this script checks some system integrity. the idea is to run these scripts on the target machine but on mounted volume without any chrooted environment. to achieve this I should mock some apps (I can do it using execHandler), mock dirs and files functions (stat, opendirhandler, substitute any paths in variables/arguments using the parser).
Now the StatHandlerFunc contains a Context. cwd
argument removed and replaced with the absPath constructor in the parent function.
This feature allows intercepting the os.stat/os.Lstat operations in the interp to provide more flexible usage.