mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 06:42:28 +00:00
Read file incrementally
This commit is contained in:
parent
bfcbf3b5bf
commit
01f61cefcb
@ -6,6 +6,8 @@
|
||||
#include "users.hh"
|
||||
#include "json-utils.hh"
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <regex>
|
||||
#include <glob.h>
|
||||
|
||||
@ -109,14 +111,17 @@ void Args::parseCmdline(const std::string & programName, const Strings & _cmdlin
|
||||
if (isNixCommand && cmdline.size() > 0) {
|
||||
auto script = *cmdline.begin();
|
||||
try {
|
||||
auto lines = tokenizeString<Strings>(readFile(script), "\n");
|
||||
if (std::regex_search(lines.front(), std::regex("^#!"))) {
|
||||
lines.pop_front();
|
||||
std::ifstream stream(script);
|
||||
char shebang[3]={0,0,0};
|
||||
stream.get(shebang,3);
|
||||
if (strncmp(shebang,"#!",2) == 0){
|
||||
for (auto pos = std::next(cmdline.begin()); pos != cmdline.end();pos++)
|
||||
savedArgs.push_back(*pos);
|
||||
cmdline.clear();
|
||||
|
||||
for (auto line : lines) {
|
||||
std::string line;
|
||||
std::getline(stream,line);
|
||||
while (std::getline(stream,line) && !line.empty()){
|
||||
line = chomp(line);
|
||||
|
||||
std::smatch match;
|
||||
|
Loading…
Reference in New Issue
Block a user