From 53c907ca09bf8ba9c2165eb74c915599768f5155 Mon Sep 17 00:00:00 2001 From: Wouter den Breejen Date: Tue, 14 Aug 2007 17:54:05 +0000 Subject: [PATCH] Fixed ugly '--hello' exception in builder.pl --- corepkgs/buildenv/builder.pl.in | 15 +-------------- src/libmain/shared.cc | 6 ++++-- src/nix-state/nix-state.cc | 17 ++++++----------- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/corepkgs/buildenv/builder.pl.in b/corepkgs/buildenv/builder.pl.in index e2258783f..bea619a40 100755 --- a/corepkgs/buildenv/builder.pl.in +++ b/corepkgs/buildenv/builder.pl.in @@ -116,22 +116,9 @@ sub createLinks { } } - # if only my GF were this dirty ... - # TODO ... sysopen (DSTFILEHANDLE, $new_dstFile, O_RDWR|O_EXCL|O_CREAT, 0755); printf DSTFILEHANDLE "#! @shell@ \n"; - printf DSTFILEHANDLE "args2=( ) \n"; - printf DSTFILEHANDLE "for arg in \"\$@\" \n"; - printf DSTFILEHANDLE "do \n"; - printf DSTFILEHANDLE " if [ \"\$arg\" = \"--help\" ]; then \n"; - printf DSTFILEHANDLE " args2=( \"\${args2[@]}\" \"\\--help\" ) \n"; - printf DSTFILEHANDLE " elif [ \"\$arg\" = \"--version\" ]; then \n"; - printf DSTFILEHANDLE " args2=( \"\${args2[@]}\" \"\\--version\" ) \n"; - printf DSTFILEHANDLE " else \n"; - printf DSTFILEHANDLE " args2=( \"\${args2[@]}\" \"\$arg\" ) \n"; - printf DSTFILEHANDLE " fi \n"; - printf DSTFILEHANDLE "done \n"; - printf DSTFILEHANDLE "/nixstate/nix/bin/nix-state --run --identifier=$new_stateIdentifier $srcFile \"\${args2[@]}\" \n"; #TODO !!!!!!!!!! fix hard link + printf DSTFILEHANDLE "/nixstate/nix/bin/nix-state --run --identifier=$new_stateIdentifier $srcFile \"\$@\" \n"; #TODO !!!!!!!!!! fix hard link close (DSTFILEHANDLE); } } diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 8049f5f75..e8dac1a63 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -170,13 +170,15 @@ static void initAndRun(int argc, char * * argv) ; /* !!! obsolete - remove eventually */ else if (arg == "--no-build-output" || arg == "-Q") buildVerbosity = lvlVomit; + + //we need to push back since arguments need to be passed on in the state wrapper script else if (arg == "--help") { printHelp(); - return; + remaining.push_back(arg); } else if (arg == "--version") { std::cout << format("%1% (Nix) %2%") % programId % NIX_VERSION << std::endl; - return; + remaining.push_back(arg); } else if (arg == "--keep-failed" || arg == "-K") keepFailed = true; diff --git a/src/nix-state/nix-state.cc b/src/nix-state/nix-state.cc index d164c1450..79aec3afe 100644 --- a/src/nix-state/nix-state.cc +++ b/src/nix-state/nix-state.cc @@ -44,7 +44,8 @@ bool revert_recursively = false; void printHelp() { - cout << string((char *) helpText, sizeof helpText); + printMsg(lvlInfo, format("%1%") % helpText); + //cout << string((char *) helpText, sizeof helpText); } Derivation getDerivation(const string & fullPath, const Strings & program_args, string state_identifier, Path & componentPath, Path & statePath, @@ -108,9 +109,6 @@ Derivation getDerivation_andCheckArgs_(Strings opFlags, Strings opArgs, Path & c opArgs.pop_front(); for (Strings::iterator i = opArgs.begin(); i != opArgs.end(); ++i){ string arg = *i; - if(arg == "\\--help" || arg == "\\--version") - arg = arg.substr(1, arg.length()); - //printMsg(lvlError, format("Args: %1%") % arg); program_args.push_back(arg); } @@ -499,16 +497,13 @@ static void opRunComponent(Strings opFlags, Strings opArgs) string root_args = ""; for (Strings::iterator i = root_program_args.begin(); i != root_program_args.end(); ++i){ - - if(*i == "--help") - printMsg(lvlInfo, format("%1%\n------------------------------------------------------------") % helpText); - if(*i == "--version") - printMsg(lvlInfo, format("%1% (Nix) %2%\n------------------------------------------------------------") % programId % NIX_VERSION ); - + if(*i == "--help" || *i == "--version") + printMsg(lvlError, format("%1%") % padd("", '-', 100)); + //printMsg(lvlError, format("ARG %1%") % *i); root_args += " \"" + *i + "\""; } - //printMsg(lvlError, format("Command: '%1%'") % (root_componentPath + root_binary + root_args)); + printMsg(lvlError, format("Command: '%1%'") % (root_componentPath + root_binary + root_args)); executeShellCommand(root_componentPath + root_binary + root_args); }