Created
August 8, 2011 20:26
-
-
Save shlevy/1132646 to your computer and use it in GitHub Desktop.
Patch to add --from-file option to nix commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Index: nix/src/libmain/shared.cc | |
| =================================================================== | |
| --- nix/src/libmain/shared.cc (revision 28396) | |
| +++ nix/src/libmain/shared.cc (working copy) | |
| @@ -7,6 +7,7 @@ | |
| #include "misc.hh" | |
| #include <iostream> | |
| +#include <fstream> | |
| #include <cctype> | |
| #include <exception> | |
| @@ -251,6 +252,20 @@ | |
| string value = *i; | |
| overrideSetting(name, tokenizeString(value)); | |
| } | |
| + else if (arg == "--from-file") { | |
| + ++i; | |
| + if (i == args.end()) throw UsageError("`--from-file' requires an argument"); | |
| + std::ifstream argFile; | |
| + argFile.open(i->c_str()); | |
| + if (argFile.fail()) { | |
| + throw Error(format("failed to open option file `%1%'") % *i); | |
| + } | |
| + string fileArg; | |
| + while (argFile >> fileArg) { | |
| + args.push_back(fileArg); | |
| + } | |
| + argFile.close(); | |
| + } | |
| else remaining.push_back(arg); | |
| } | |
| Index: nix/doc/manual/opt-common.xml | |
| =================================================================== | |
| --- nix/doc/manual/opt-common.xml (revision 28396) | |
| +++ nix/doc/manual/opt-common.xml (working copy) | |
| @@ -341,6 +341,16 @@ | |
| </varlistentry> | |
| +<varlistentry><term><option>--from-file</option> <replaceable>file</replaceable></term> | |
| + | |
| + <listitem><para>This option reads whitespace-separated options | |
| + from <replacable>file</replacable> and adds them to the argument list. | |
| + This can be particularly useful if <replacable>file</replacable> | |
| + is /dev/stdin.</para></listitem> | |
| + | |
| +</varlistentry> | |
| + | |
| + | |
| </variablelist> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment