]> git.ipfire.org Git - thirdparty/util-linux.git/commit
lib/tt: always escape '\' to simplify parsing in scripts
authorKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 12:23:04 +0000 (14:23 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 12:34:47 +0000 (14:34 +0200)
commit17b1c1368de17d31e053d4bef3f2e0a74bbbd73b
treee39f3d33dd3a5a40cd8fc14d771edeb9e73e2d12
parent33e785491b073ffe8a5f7546d214b8340ad29394
lib/tt: always escape '\' to simplify parsing in scripts

The commands echo(1) and printf(1) are usable for escape sequences
decoding, for example

 for x in $(findmnt --noheading --raw --output TARGET); do
  printf "%b" $x
 done

but it's necessary to escape all '\' chars, otherwise for example \b
in foo\bar will be interpreted as backspace. It means that for example
findmnt(8) has to use \x5c for the backslash.

  # findmnt --noheading --raw --output TARGET /dev/sda1
  /mnt/ugly/foo\x5cbar

Reported-by: Pádraig Brady <P@draigBrady.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/tt.c