Ambiguous output from tree with respect to symbolic links

The name of the pictureThe name of the pictureThe name of the pictureClash 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:




  1. -q will make tree display unprintable characters as ?. Any effect they might have on the output is negated.


  2. -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?










share|improve this question























  • 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














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:




  1. -q will make tree display unprintable characters as ?. Any effect they might have on the output is negated.


  2. -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?










share|improve this question























  • 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












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:




  1. -q will make tree display unprintable characters as ?. Any effect they might have on the output is negated.


  2. -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?










share|improve this question















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:




  1. -q will make tree display unprintable characters as ?. Any effect they might have on the output is negated.


  2. -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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 of tree 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










  • Why are you wanting to do this? Are you parsing the output of tree 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















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay