Skip to main content
23 events
when toggle format what by license comment
Nov 11, 2018 at 22:52 comment added babou @ivan_pozdeev That was 5 years ago and I do not remember the exact path of my thinking. I had read all the answers, and was aware of possible traps. If the intent of the OP should be followed the way you state, then all the answers suggesting readlink are wrong (do not forget downvoting them :). One had more than 100 upvote when I answered. Though symlinks may be expanded, I was aware that it is often undesirable (as you imply too), but I tried to address the isssue constructively since it could help some users. Explaining why one choice may be better than the other is also an answer.
Nov 11, 2018 at 20:56 comment added ivan_pozdeev All I implied is that the algorithm I gave is the "default" one, the one implied when "absolute path" is mentioned without any further qualifications. The OP didn't ask for "all possible absolute paths" so unless they say otherwise, this is implied. Judging by the OP's actions though, they were fine with any of the possible answers.
Nov 11, 2018 at 17:42 comment added babou @ivan_pozdeev May I point out that your first comment makes the same mistake as the OP. What you describe is one way to get an absolute path. It is not the only one, and they do not all give the same result. And you call it the algorithm, thereby implying that it is unique, or at least that they all give equivalent result, which is wrong. What right do you have to present your answer a the unique one, especially if you know there are others, but do not know which is more appropriate.
Nov 11, 2018 at 17:14 comment added babou @ivan_pozdeev In no way a remark on other answers. First, the question is bad. That is my first remark on my original (short) answer. I made it longer as users missed the point which is obviously more subtle than expected. Answers are given, but incomplete regarding use. One can say the OP did not ask, but the phrasing of his question made it clear he was missing a point. I was not commenting on other questions, but giving an answer complete enough to take into account whatever hidden but essential information may be at stakes, unbeknownst to OP. This does agree with SO policies.
Nov 11, 2018 at 16:05 comment added ivan_pozdeev So this is a remark on other answers and does not give any answers itself. That's what was rubbing me the wrong way: these are off topic at SO.
Nov 11, 2018 at 16:05 review Low quality answers
Nov 11, 2018 at 18:41
Nov 11, 2018 at 13:43 comment added babou @ivan_pozdeev Busy week. Could not answer earlier (stuff is 5 years old). The question was asking for a single command. Your answer is composite. The accepted answer suggested realpath which is a single command. Another is readlink. But no one explains what they do, and the result may be adequate, or not, because there is no unicity of absolute path (while unicity is implied in the question), and they do not always behave identically, depending on later use. Your answer may not be right depending on context, on intended use of result, which is a piece of text to be interpreted later.
Nov 8, 2018 at 14:00 comment added ivan_pozdeev I fail to see what this answer is preaching. The algorithm of absolutizing a path is quite clear and unambiguous: absolute_path = path if is_absolute(path) else current_dir + sep + path. Who cares that many absolute paths are possible if the FS supports symlinks? This question does not ask how to compare them!
May 23, 2017 at 12:34 history edited URL Rewriter Bot
replaced http://stackoverflow.com/ with https://stackoverflow.com/
May 29, 2013 at 12:00 comment added babou 4 - Short answers are very often more useful than long lectures. You are absolutely right. If you go back to my original answer you will see that it was only 8 lines. Being downvoted without explanation, I assumed I had to be more precise, though I did not even know whether the problem was technical or linguistic. I started working on this text for my own sake, leaving it there because it was convenient and because I was still hoping to get reactions. But the same question is asked in too many places.
May 29, 2013 at 11:59 comment added babou 3 - Since there are many solutions suggested as answers, it may be useful to readers to get a comparative assessment of the answers, to get to understand the why as well as to know the how. I happen to agree with you on the answer, but that is immaterial. It took me some time (much more than you would think) to be comfortable with that assessment, and I try to spare that work to others. Sometimes I edit my own questions to explain, afterwards, why I chose a given answer, so as to help future readers. Actually there seems to be a bit of controversy regarding realpath and readlink.
May 29, 2013 at 11:58 comment added babou 2 - You insist that there is a (single) absolute path corresponding to a relative path. While I do guess what you mean by "corresponding", i.e. a path derived from the original through a given set of transformations, your statement is still incorrect. There is a unique "corresponding" canonical path. The word canonical refers precisely to this uniqueness relative to a set of transformations. But, for example, /dev/cdrom is a perfectly good absolute path, even though it is actually a link to /dev/sr0. Both point to the same device. My original answer pointed to a relevant web article.
May 29, 2013 at 11:58 comment added babou 1- the fact that a question has had a valid answer for however long does not mean that it is closed. The questions are not intended for personnal use only. Indeed, there are badges for replies that collect more votes than the validated answer. And with new tools, the "best" answer can change over time. Many people use old answers accessed through web search.
May 29, 2013 at 11:57 comment added babou @dhardy Thank you for taking the time for a detailed answer. I find it really helpful to understand communication intercourse on this site, and to clarify my own thoughts on this topic. Regarding the specific issues you raise, please allow me to reply to them in more detail.
May 28, 2013 at 18:58 comment added dhardy Second comment: short answers are very often more useful than long lectures. Stack overflow is usually used to ask specific questions.
May 28, 2013 at 18:56 comment added dhardy (a) the question has a valid answer from 2+1/2 years ago, (b) there is a (single) absolute path corresponding to a relative path (which is what I wanted), though maybe not to a file as you pointed out. BTW any comments about realpath vs readlink or even about symbolic links are surplus to what I asked.
May 26, 2013 at 22:38 history edited babou CC BY-SA 3.0
minor
May 26, 2013 at 22:32 history edited babou CC BY-SA 3.0
reorganized and expanded the answer.
May 24, 2013 at 10:31 history edited babou CC BY-SA 3.0
added explanation for the linguistically challenged reader
May 20, 2013 at 16:44 history edited babou CC BY-SA 3.0
added a reference
May 20, 2013 at 15:35 comment added babou I do not mind being downvoted, but I like to understand why so that I can learn something, either technical or regarding what is considered proper practice on the site. Well ... at least it induced me to register with Meta Stack Overflow to better understand local sociology. I do recommend it. -- Still, if anyone has an opinion about the inappropriateness of my answer, I am interested.
May 19, 2013 at 17:56 review Late answers
May 19, 2013 at 17:59
May 19, 2013 at 17:40 history answered babou CC BY-SA 3.0