From 99f27d5eb16db453b4412970abb0421e927a3cbf Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Thu, 4 Dec 2014 18:10:30 +0100 Subject: [PATCH] Fix pwd(1) unsetting PWD and exit code. --- utils/pwd.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/pwd.cpp b/utils/pwd.cpp index a2948a91..923152db 100644 --- a/utils/pwd.cpp +++ b/utils/pwd.cpp @@ -1,6 +1,6 @@ /******************************************************************************* - Copyright(C) Jonas 'Sortie' Termansen 2013. + Copyright(C) Jonas 'Sortie' Termansen 2013, 2014. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -123,7 +123,7 @@ int main(int argc, char* argv[]) if ( const char* pwd = getenv("PWD") ) { if ( physical || !is_path_absolute(pwd) ) - unsetenv(pwd); + unsetenv("PWD"); } char* pwd = get_current_dir_name(); @@ -132,5 +132,8 @@ int main(int argc, char* argv[]) printf("%s\n", pwd); + if ( ferror(stdout) || fflush(stdout) == EOF ) + error(1, errno, "stdout"); + return 0; }