INNER CODE UNIT · TypeScript

quote

NVIDIA/NemoClaw · .dsh/tools/check_changed_files_for_nul_bytes/index.ts:25

  const quote = (value) => "'" + String(value).replaceAll("'", "'\"'\"'") + "'";
  const files = [];
  const findings = [];
  const deadline = Date.now() + 30000;
  for (const file of changed.files) {
    const remainingMs = deadline - Date.now();
    if (remainingMs <= 0) throw new Error("Could not scan changed files");
    const result = await tools.bash({
      command:
        "set -o pipefail; if [ ! -f " +
        quote(file) +
        " ]; then exit 3; fi; LC_ALL=C od -An -v -t u1 -- " +
        quote(file) +
        " | awk '{ for (i = 1; i <= NF; i++) if ($i == 0) count++ } END { print count + 0 }'",
      workdir: input.workdir,
      description: "Count NUL bytes in changed file",
      timeoutMs: remainingMs,
    });

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…