Ph0enixKM / Amber

💎 Amber the programming language compiled to bash
https://amber-lang.com
GNU General Public License v3.0
3.51k stars 67 forks source link

Flag to run the script in a /tmp folder #242

Open Mte90 opened 3 days ago

Mte90 commented 3 days ago

It is the same stuff for https://github.com/Ph0enixKM/Amber/issues/219 or https://github.com/Ph0enixKM/Amber/issues/223

The idea is to have a flag that you put on top of the Amber script that automatically with mktemp -d create a temporary folder and move the PWD/CWD to that.

CymDeveloppement commented 3 days ago

a few years ago, I used a preprocessor written in PHP for my bash script. It was used to replace keywords with code snippets. i think a similar system can be used especially for this

for example : #[execute_in_temp_folder] replaced by unsafe $mktemp -d$

in my preprocessor the use was mainly for dependencies, this could solve dependency checker for example : #[depends:dialog/dialog] replaced by unsafe $if ! [ -x "\$(command -v dialog)" ];then echo \$"dialog command could not be found, install package dialog";exit 1; fi;$ and many other..

all my snippets were stored in a file, one file by snippet

Mte90 commented 3 days ago

Yes can be an attribute, for the dependency there is another ticket https://github.com/Ph0enixKM/Amber/issues/95

b1ek commented 1 day ago

what is exactly the point of this feature though?

Mte90 commented 1 day ago

Usually scripts run in a folder dedicated so they don't mess with the system. Like file editing and so on, the idea is to have like a sandbox generated automatically and the cwd/pwd.