脚本中:

echo ${HOME}

C中:

#include <stdlib.h>
char *home_path = getenv("HOME");

printf("home_path=%s\n", home_path);