$file, 'lineNo' => $lineNo, 'charNo' => $charNo, 'category' => $category, 'msg' => $msg, 'name' => $name, ); $csvRowNum++; } fclose($fh); } foreach ($linesByError as $name => $items) { $msgs = array(); foreach ($items as $item) { $msgs[$item['msg']] = 1; } $buf = "#!/bin/bash\n"; $buf .= "## usage: bash cleanup-$name.sh vi\n"; $buf .= "## usage: bash cleanup-$name.sh joe\n"; $buf .= ' [ -n "$1" ] && EDITOR="$1" if [ -z "$EDITOR" ]; then echo "Please provide parameter 1 (editor). Example: vi, joe" exit 1 fi function edit_at_line() { local f="$1" local l="$2" $EDITOR +$l "$f" } '; $buf .= "echo Process cleanup for " . escapeshellarg($name) . "\n"; $buf .= "echo Number of lines: " . count($items) . "\n"; $buf .= "echo Examples: " . escapeshellarg(print_r(array_keys($msgs), TRUE)) . "\n"; $buf .= "echo Press ENTER to begin\n"; $buf .= "read\n"; foreach ($items as $item) { $file = preg_replace(':^.*modules/civicrm/:', '', $item['file']); $buf .= sprintf("edit_at_line %s %s\n", escapeshellarg($file), $item['lineNo']); } file_put_contents($outDir . "/cleanup-" . $name . '.sh', $buf); }