Signal9Signal9 — home
online
back to labs

Fleet Refactor: One :argdo, Zero Collateral

HardText Editors20-30 min
The brief

A config key has been renamed, and every file in the fleet needs the change. /root/case/assignment.env names the fleet directory, the old key and the new key (they differ per session, as do the files).

In every fleet file, /root/fleet/*.conf, each active line that sets the old key (OLDKEY=<value> at the start of a line) must become NEWKEY=<value>, with the same value. Nothing else may change:

  • other keys that merely contain the old name are different settings;
  • commented-out lines (# OLDKEY=…) are history, so leave them as written;
  • /root/fleet/archive/ and /root/fleet/template.conf.example are not part of the fleet;
  • some fleet files don't set the key at all, and that's fine.

In vim: load the fleet as the argument list, then one :argdo with an anchored substitution and | update. Grading compares every file with the exact expected content, so any tool passes, but only a precise edit does.

What you'll do
  • Load a set of files into vim's argument list
  • Run one substitution across every file with :argdo
  • Anchor a pattern so lookalike keys and comments are untouched
  • Save only the files that changed with update

Hands-on lab: you work on a real Linux box in your browser, graded on the machine's actual state.