From 9a259a93ca5e70c2938debbb9ffc073f529ea306 Mon Sep 17 00:00:00 2001 From: asus Date: Wed, 31 Jan 2024 22:18:34 +0100 Subject: [PATCH] some explanations in create_env --- srcs/model.env | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/srcs/model.env b/srcs/model.env index 7db6fd5..e9a1bd9 100644 --- a/srcs/model.env +++ b/srcs/model.env @@ -31,6 +31,32 @@ WP_USER_EMAIL=moehu36@42.fr EXECUTION_TIME=300 +# if you want to get the home directory you can use $(HOME) +# however, this will not give the same result if you use sudo, ex : +# ./create_env : /home/asususus +# sudo ./create_env : /root +# but you can use this command `eval echo "~$SUDO_USER"` to get +# the home directory of the user using sudo, it works in non-sudo also : +# - echo "$SUDO_USER" : +# - in normal mode it outputs : "" +# - in sudo mode it outputs the user : "username" +# - same as $USER in normal mode +# - echo "~$SUDO_USER" : +# - in linux "~USER" is the home directory of a user +# - but echo "something" will treat ~ as a string litteral +# - so the output in mormal mode will be : "~" +# - and in sudo mode it will be : "~username" +# - eval echo "~$SUDO_USER" : +# - eval will evaluate the expression and perform expansion one more time +# - so it will evaluate the output of `echo "~$SUDO_USER"` +# - in normal mode : +# - it will evaluate : "~" +# - and ouptput : "/home/username" +# - in sudo mode : +# - it will evaluate : "~username" +# - and output : "/home/username" +# - because "~username" expand in the home (~) directory of given user +# https://stackoverflow.com/questions/77088135/makefile-subst-doesnt-use-make-variable-as-expected HOME_PATH=$(eval echo "~$SUDO_USER") HOST_VOLUME_WP=${HOME_PATH}/data/lejourduprof/wp_volume