Ich benutze jsonlint, um eine Reihe von Dateien in einem Verzeichnis (rekursiv) zu fusseln. Ich schrieb den folgenden Befehl ein:xargs Befehl Länge Grenzen
find ./config/pages -name '*.json' -print0 | xargs -0I % sh -c 'echo Linting: %; jsonlint -V ./config/schema.json -q %;'
Es funktioniert für die meisten Dateien, aber einige Dateien, die ich die folgende Fehlermeldung erhalten:
Linting: ./LONG_FILE_NAME.json
fs.js:500
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: ENOENT, no such file or directory '%'
Es scheint für lange Dateinamen zu scheitern. Gibt es eine Möglichkeit, das zu beheben? Vielen Dank.
Bearbeiten 1: Das Problem gefunden.
-I replstr
Execute utility for each input line, replacing one or more occurrences of replstr in up to replacements (or 5 if no -R flag is specified) arguments to utility with the entire line of input. The resulting arguments, after replacement is done, will not be allowed to grow beyond 255 bytes; this is implemented by concatenating as much of the argument containing replstr as possible, to the con-structed arguments to utility, up to 255 bytes. The 255 byte limit does not apply to arguments to utility which do not contain replstr, and furthermore, no replacement will be done on utility itself. Implies -x.
Edit 2: Teillösung. Unterstützt längere Dateinamen als zuvor, aber immer noch nicht so lange wie ich brauche.
find ./config/pages -name '*.json' -print0 | xargs -0I % sh -c 'file=%; echo Linting: $file; jsonlint -V ./config/schema.json -q $file;'
Sieht aus wie das Problem mit jsonlint ist, nicht xargs –
Es xargs ist, dachte ich, das Problem einfach nicht eine große Lösung. Siehe Änderungen. –
Sie können 'xargs' sagen, eine json-Datei gleichzeitig zu verarbeiten, indem Sie' -n 1' übergeben. Oder vielleicht einige Dateien weniger als die Bruchstelle zu einer Zeit durch die Weitergabe von "-n 20" zum Beispiel .. – alvits