Ambiguous output from tree with respect to symbolic links
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Whenever I use command line tools, I like to make sure that the output can be interpreted unambiguously. On one of my other machines, I wrote a shell script that would find all of the symbolic links residing under a particular path and it would print them to the console so that it would look like "<Escaped Path To Symbolic Link>" e[91m=>e[0m "<Escaped Path To Target>"
. The ANSI escape codes are parsed in that script; <Escaped Path To Symbolic Link>
and <Escaped Path To Target>
are the paths to the symbolic link and its target, respectively, with any non-printable characters escaped so that they come out as xHH
on the console (where H
is a hexadecimal digit).
In the above, there is no ambiguity. If either the symbolic link or its target path contain =>
, it will be distinguishable from the delimiter separating because the delimiter will be displayed as red text. If either path contains an ANSI escape code, then the escape character will appear on the console as e
, eliminating any chance that there could be anything other than one red =>
. A newline would be rendered as n
and double quotes would appear as "
.
I am aware of three ways that further disambiguate the output of tree
in some way:
-q
will maketree
display unprintable characters as?
. Any effect they might have on the output is negated.-C
turns colorization on. If this is used in conjunction with-F
, then the appended characters will be distinguishable from the names they are affixed to by being a different color. In this way, a file whose name ends with an equal sign will be distinguishable from a socket.
Using both options still leaves it ambiguous as to what character any ?
that has been substituted for an unprintable one represents and is not distinguishable from question marks that are actually part of the file or folder's name. If the sequence ->
, which is used to indicate what a symbolic link points to, is in a path, then it is distinguishable thanks to spaces in paths being converted to .
How can I make the output completely unambiguous?
tree
add a comment |Â
up vote
0
down vote
favorite
Whenever I use command line tools, I like to make sure that the output can be interpreted unambiguously. On one of my other machines, I wrote a shell script that would find all of the symbolic links residing under a particular path and it would print them to the console so that it would look like "<Escaped Path To Symbolic Link>" e[91m=>e[0m "<Escaped Path To Target>"
. The ANSI escape codes are parsed in that script; <Escaped Path To Symbolic Link>
and <Escaped Path To Target>
are the paths to the symbolic link and its target, respectively, with any non-printable characters escaped so that they come out as xHH
on the console (where H
is a hexadecimal digit).
In the above, there is no ambiguity. If either the symbolic link or its target path contain =>
, it will be distinguishable from the delimiter separating because the delimiter will be displayed as red text. If either path contains an ANSI escape code, then the escape character will appear on the console as e
, eliminating any chance that there could be anything other than one red =>
. A newline would be rendered as n
and double quotes would appear as "
.
I am aware of three ways that further disambiguate the output of tree
in some way:
-q
will maketree
display unprintable characters as?
. Any effect they might have on the output is negated.-C
turns colorization on. If this is used in conjunction with-F
, then the appended characters will be distinguishable from the names they are affixed to by being a different color. In this way, a file whose name ends with an equal sign will be distinguishable from a socket.
Using both options still leaves it ambiguous as to what character any ?
that has been substituted for an unprintable one represents and is not distinguishable from question marks that are actually part of the file or folder's name. If the sequence ->
, which is used to indicate what a symbolic link points to, is in a path, then it is distinguishable thanks to spaces in paths being converted to .
How can I make the output completely unambiguous?
tree
Which version? My tree 1.7.0 manpage lists a-N
option: "Print non-printable characters as is instead of as escaped octal numbers."
â muru
Sep 25 at 17:55
Why are you wanting to do this? Are you parsing the output oftree
for some other purpose?
â Kusalananda
Sep 25 at 18:32
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Whenever I use command line tools, I like to make sure that the output can be interpreted unambiguously. On one of my other machines, I wrote a shell script that would find all of the symbolic links residing under a particular path and it would print them to the console so that it would look like "<Escaped Path To Symbolic Link>" e[91m=>e[0m "<Escaped Path To Target>"
. The ANSI escape codes are parsed in that script; <Escaped Path To Symbolic Link>
and <Escaped Path To Target>
are the paths to the symbolic link and its target, respectively, with any non-printable characters escaped so that they come out as xHH
on the console (where H
is a hexadecimal digit).
In the above, there is no ambiguity. If either the symbolic link or its target path contain =>
, it will be distinguishable from the delimiter separating because the delimiter will be displayed as red text. If either path contains an ANSI escape code, then the escape character will appear on the console as e
, eliminating any chance that there could be anything other than one red =>
. A newline would be rendered as n
and double quotes would appear as "
.
I am aware of three ways that further disambiguate the output of tree
in some way:
-q
will maketree
display unprintable characters as?
. Any effect they might have on the output is negated.-C
turns colorization on. If this is used in conjunction with-F
, then the appended characters will be distinguishable from the names they are affixed to by being a different color. In this way, a file whose name ends with an equal sign will be distinguishable from a socket.
Using both options still leaves it ambiguous as to what character any ?
that has been substituted for an unprintable one represents and is not distinguishable from question marks that are actually part of the file or folder's name. If the sequence ->
, which is used to indicate what a symbolic link points to, is in a path, then it is distinguishable thanks to spaces in paths being converted to .
How can I make the output completely unambiguous?
tree
Whenever I use command line tools, I like to make sure that the output can be interpreted unambiguously. On one of my other machines, I wrote a shell script that would find all of the symbolic links residing under a particular path and it would print them to the console so that it would look like "<Escaped Path To Symbolic Link>" e[91m=>e[0m "<Escaped Path To Target>"
. The ANSI escape codes are parsed in that script; <Escaped Path To Symbolic Link>
and <Escaped Path To Target>
are the paths to the symbolic link and its target, respectively, with any non-printable characters escaped so that they come out as xHH
on the console (where H
is a hexadecimal digit).
In the above, there is no ambiguity. If either the symbolic link or its target path contain =>
, it will be distinguishable from the delimiter separating because the delimiter will be displayed as red text. If either path contains an ANSI escape code, then the escape character will appear on the console as e
, eliminating any chance that there could be anything other than one red =>
. A newline would be rendered as n
and double quotes would appear as "
.
I am aware of three ways that further disambiguate the output of tree
in some way:
-q
will maketree
display unprintable characters as?
. Any effect they might have on the output is negated.-C
turns colorization on. If this is used in conjunction with-F
, then the appended characters will be distinguishable from the names they are affixed to by being a different color. In this way, a file whose name ends with an equal sign will be distinguishable from a socket.
Using both options still leaves it ambiguous as to what character any ?
that has been substituted for an unprintable one represents and is not distinguishable from question marks that are actually part of the file or folder's name. If the sequence ->
, which is used to indicate what a symbolic link points to, is in a path, then it is distinguishable thanks to spaces in paths being converted to .
How can I make the output completely unambiguous?
tree
tree
edited Sep 25 at 17:52
muru
33.9k578147
33.9k578147
asked Sep 25 at 17:48
Melab
82211221
82211221
Which version? My tree 1.7.0 manpage lists a-N
option: "Print non-printable characters as is instead of as escaped octal numbers."
â muru
Sep 25 at 17:55
Why are you wanting to do this? Are you parsing the output oftree
for some other purpose?
â Kusalananda
Sep 25 at 18:32
add a comment |Â
Which version? My tree 1.7.0 manpage lists a-N
option: "Print non-printable characters as is instead of as escaped octal numbers."
â muru
Sep 25 at 17:55
Why are you wanting to do this? Are you parsing the output oftree
for some other purpose?
â Kusalananda
Sep 25 at 18:32
Which version? My tree 1.7.0 manpage lists a
-N
option: "Print non-printable characters as is instead of as escaped octal numbers."â muru
Sep 25 at 17:55
Which version? My tree 1.7.0 manpage lists a
-N
option: "Print non-printable characters as is instead of as escaped octal numbers."â muru
Sep 25 at 17:55
Why are you wanting to do this? Are you parsing the output of
tree
for some other purpose?â Kusalananda
Sep 25 at 18:32
Why are you wanting to do this? Are you parsing the output of
tree
for some other purpose?â Kusalananda
Sep 25 at 18:32
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f471387%2fambiguous-output-from-tree-with-respect-to-symbolic-links%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Which version? My tree 1.7.0 manpage lists a
-N
option: "Print non-printable characters as is instead of as escaped octal numbers."â muru
Sep 25 at 17:55
Why are you wanting to do this? Are you parsing the output of
tree
for some other purpose?â Kusalananda
Sep 25 at 18:32