It probably makes more sense to use getenv("HOME") in a command line script ;) That should also avoid showing a warning if it's not set.