Printing C:\abc in a portable way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I want to print C:\abc in a portable way. Or rather, store the value C:\abc in a variable. I have bash 5.2.15-3.fc38 and dash 0.5.12-1.fc38. /bin/sh is a symlink to bash.

In interactive bash

echo "C:\\abc"

prints

C:\abc . The same happens when I store in a file and execute it:

#!/bin/bash
echo "C:\\abc"


#!/bin/bash --posix
echo "C:\\abc"


#!/bin/sh
echo "C:\\abc"

With dash it is different:

#!/bin/dash
echo "C:\\abc"

prints C:bc . When I replace above a with k, echo "C:\\kbc" prints C:\kbc .

When I replace the double quotes with single quotes, echo 'C:\\abc' , dash prints C:\abc, but bash (interactive, /bin/sh and bash --posix) prints C:\\abc .

All that said I think this is a bug in dash.

The above echos are simplified use case, in reality I want to execute A="C:\\abc" ./script and the script shall see C:\abc as value to the variable A.

Kind regards
  Dilyan



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux