github.com/upcmd/up@v0.8.1-0.20230108151705-ad8b797bf04f/tests/functests/e0198.yml (about) 1 notes: | 2 ### Run the example 3 4 up ngo -p pure-env-vars -d ./tests/functests -t e0198.yml --configdir=./tests/functests 5 6 ### Use pure flag in eprofile 7 8 Sometimes when you start a cli program, you would like all the env vars are statically declared from within your shell script or rc file, but not inherited from current shell session context 9 10 In order to achieve this, we can use the pure flag in the eprofile 11 12 When you state pure to be ture, it will clean up and unset all existing env vars from the inherited shell context 13 14 ### What about I want to do the same to set pure if start the task without using eprofile? 15 16 In this case, it is a matter to just use cmd: virtualEnv, then use pure arg 17 18 Refer to c0193 for example 19 20 ### Exec log 21 22 The expected result is that it will unset all env vars and leave only the declared PERSON_NAME there in the context 23 24 Please note that there are still a few contextual env vars showing. This is because they are the one required by the shell execution and can not be unset 25 26 ``` 27 28 /up-project/up git:(master) ▶ up ngo -p pure-env-vars -d ./tests/functests -t e0198.yml --configdir=./tests/functests 29 loading [Config]: ./tests/functests/upconfig.yml 30 Main config: 31 Version -> 1.0.0 32 RefDir -> ./tests/functests 33 WorkDir -> cwd 34 AbsWorkDir -> /up-project/up 35 TaskFile -> e0198.yml 36 Verbose -> v 37 ModuleName -> self 38 ShellType -> /bin/sh 39 MaxCallLayers -> 8 40 Timeout -> 3600000 41 MaxModuelCallLayers -> 256 42 EntryTask -> Main 43 work dir: /up-project/up 44 -exec task: Main 45 loading [Task]: ./tests/functests/e0198.yml 46 module: [self], instance id: [nonamed], exec profile: [pure-env-vars] 47 -set pure env context done. 48 Task1: [task ==> task: ] 49 -Step1: 50 cmd( 1): 51 - 52 my pre-set env var: Peter-Jackson 53 ================================= 54 PERSON_NAME=Peter-Jackson 55 PWD=/up-project/up 56 SHLVL=1 57 _=/usr/bin/env 58 59 - 60 .. ok 61 . ok 62 63 ``` 64 65 66 eprofiles: 67 - name: pure-env-vars 68 taskname: task 69 pure: true 70 desc: | 71 a test profile starting with a pure env vars environment 72 meaning the execution shell session will unset all inherited env vars from caller's context 73 evars: 74 - name: PERSON_NAME 75 value: Peter-Jackson 76 77 tasks: 78 79 - 80 name: task 81 task: 82 - 83 func: shell 84 do: | 85 echo """my pre-set env var: $PERSON_NAME""" 86 echo "=================================" 87 env|grep =