[Git-commits] [grml/grml-live] 05bc99: grml-setlang: fix symlink breakage

Chris Hofstaedtler noreply at github.com
Wed Jun 18 20:21:44 CEST 2025


  Branch: refs/heads/zeha/langkbd
  Home:   https://github.com/grml/grml-live
  Commit: 05bc99b8d71cceb7b6064447e7faa9935b943ab3
      https://github.com/grml/grml-live/commit/05bc99b8d71cceb7b6064447e7faa9935b943ab3
  Author: Chris Hofstaedtler <ch at grml.org>
  Date:   2025-06-18 (Wed, 18 Jun 2025)

  Changed paths:
    M config/files/GRMLBASE/usr/sbin/grml-setlang

  Log Message:
  -----------
  grml-setlang: fix symlink breakage

Claude Code prompts:

```
> At runtime, /etc/default/locale starts out as a symlink to /etc/locale.conf. After grml-setlang has run,
  /etc/default/locale and /etc/locale.conf are two separate files, with different contents. Please afix this.

...

> FYI, /etc/locale.conf is created by the systemd package, and /etc/default/locale is symlinked to it by debian's
  locales package.

⏺ Thank you for the clarification! Now I understand the setup. Since /etc/default/locale is a symlink to
  /etc/locale.conf created by the locales package, when grml-setlang writes to /etc/default/locale, it's actually
  writing to the symlink target (/etc/locale.conf), but then it creates a new /etc/default/locale file, breaking the
  symlink.

...

⏺ I can see the issue. The problem is that when grml-setlang runs, it either creates a new file (lines 212-228) or
  modifies the existing file using sed -i and echo >> operations (in the setvalue function). These operations break
  the symlink because:

  1. sed -i creates a new file and replaces the original
  2. echo >> can also break symlinks depending on the shell
  3. The initial file creation (lines 212-228) definitely creates a regular file

  The fix is to ensure that when we modify /etc/default/locale, we preserve the symlink by writing to the actual
  target file /etc/locale.conf instead. Let me fix this:

...

> Please try a solution without grml-setlang having to know about /etc/default/locale being a symlink

⏺ You're right! A cleaner approach would be to modify the file operations to preserve symlinks rather than having
  grml-setlang know about the specific symlink relationship. Let me fix the setvalue function to handle symlinks
  properly:

...

> Would sed --follow-symlinks also work?

⏺ Yes! That's a much cleaner solution. The sed --follow-symlinks option (or -f) tells sed to follow symlinks to their
  target files instead of replacing them.

```

Solution path steering by Michael Prokop and me.



To unsubscribe from these emails, change your notification settings at https://github.com/grml/grml-live/settings/notifications


More information about the Git-commits mailing list