TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Dotfiles being hidden is a UNIXv2 mistake (2012)

324 点作者 varbhat将近 3 年前

40 条评论

jdlyga将近 3 年前
I love how so many behaviors we depend on were mistakes or temporary fixes<p>&quot;In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move&quot;
评论 #32431900 未加载
评论 #32430843 未加载
评论 #32432121 未加载
评论 #32435441 未加载
评论 #32429507 未加载
评论 #32431860 未加载
评论 #32429542 未加载
coldtea将近 3 年前
&gt;<i>How many bugs and wasted CPU cycles and instances of human frustration (not to mention bad design) have resulted from that one small shortcut about 40 years ago?</i><p>Not many? In the sense that, considering several UNIX and C design issues and footguns, the dotfiles are the least of our worries (compare e.g. to C buffer overflows or shell escaping rules, to name but two)...<p>I also don&#x27;t particularly like the repeated ditches at &quot;lazy programmers&quot; - isn&#x27;t the whole &quot;New Jersey&quot; style [1] heavy on laziness?<p>In fact, if those &quot;lazy programmers&quot; were given OS level-APIs and libs doing the right thing about dotfiles, they wouldn&#x27;t have recoded them on their own in their programs...<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Worse_is_better#New_Jersey_style" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Worse_is_better#New_Jersey_sty...</a>
评论 #32431874 未加载
评论 #32431752 未加载
评论 #32431726 未加载
LukeShu将近 3 年前
The code in question: <a href="https:&#x2F;&#x2F;github.com&#x2F;dspinellis&#x2F;unix-history-repo&#x2F;commit&#x2F;389a475ba0445aa2816f84796786568a762a930d#diff-02d9990bf5c5bbe1b4473ff16783b30ec389fff3ffe30189990a48b6cbf72239R120" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;dspinellis&#x2F;unix-history-repo&#x2F;commit&#x2F;389a4...</a>
评论 #32428825 未加载
评论 #32430876 未加载
评论 #32432679 未加载
PeterWhittaker将近 3 年前
Pike may be right that it was a coding error (but cf comments elsewhere re the unlikelihood that Ritchie, e.g., wouldn’t have thought of those other cases), but I think he’s wrong about it being a mistake.<p>I love dotfiles. When I list a folder, I don’t want to see all the cruft, I want to see the key stuff. Sometimes when I organizing something new, I use .directoryName to hide things temporarily.<p>git is one of my favourite examples: .git hides stuff I do NOT need to see every day, leaving behind the things I am actually working on, the things I care about.<p>Besides, it is so easy, once one has CLIed a while, to find (no pun intended) and&#x2F;or account for dot files when you need to.
评论 #32430504 未加载
评论 #32430437 未加载
kazinator将近 3 年前
&gt; <i>I&#x27;m pretty sure the concept of a hidden file was an unintended consequence. It was certainly a mistake.</i><p>That is highly implausible, except as a case of extremely distracted coding.<p>Someone like Thompson or Ritchie wouldn&#x27;t consciously write a test for just the leading dot without being fully aware that it matches more than . and .. .<p>Even if the thought had been &quot;nobody in their right mind will have files starting with dot, so who cares&quot;, that would still make it a deliberate requirement being consciously implemented and not a mistake.<p>By distracted coding I mean that situations like this happen: you intend to write a piece of code which does something specific. The code is motivated by certain happy cases. You start coding it and get it into a state in which it runs but doesn&#x27;t quite do what was intended. Then you get completely distracted by some interruption. You forget that the code hadn&#x27;t been completed; you mistake the remembered intent for the completion. You run the code and it carries out the intent on the motivating happy cases, and somehow fool yourself into believing it was done.<p>Maybe Pike meant that it was a mistake to create that requirement.<p>I don&#x27;t hate the $HOME&#x2F;cfg directory idea, but please call it $HOME&#x2F;.cfg so I don&#x27;t have to see it. :)
评论 #32435020 未加载
quickthrower2将近 3 年前
I recently learned about this &quot;mistake&quot;. I always assumed the dotfile was some design feature by ancient &quot;gurus&quot; of UNIX rather than an accident.<p>There is something nice and immediate about adding a dot to make it invisible to certain things (ls by default, the file explorers in ubuntu by default, etc.)<p>A bit like file extensions themselves and the weight they carry in Windows.<p>It sorts of balances in favour of immediacy of the function over &quot;right way to do things&quot;, where the right way might be some kind of meta data for the file, or for it&#x27;s folder.<p>Funny thing about hiding, is what does it mean to hide? If you can ask your utility to show hidden things. It sort of means &quot;things I reckon people don&#x27;t wanna see, or shouldn&#x27;t touch, unless they are willing to take a step to see it&quot;.<p>A bit like a shibboleth where if you can&#x27;t figure out how to see it, you are too dangerous&#x2F;dumb to edit it, or even know about it.<p>You could instead have security settings for that. Maybe you just don&#x27;t give the user access to the files at all until they elevate from user to &quot;poweruser&quot;. Which would be somewhere between user and superuser. Use chmod to set the permissions, instead of a dot filename format.
评论 #32433531 未加载
评论 #32435031 未加载
andrewla将近 3 年前
I am increasingly exasperated by apps that do not follow the XDG specification for config at this point. Having a ton of dotfiles sitting in the root of the home directory is just a maintenance nightmare on every level.<p>I&#x27;ve gone so far as to keep my config directory visible -- ~&#x2F;.config is a symlink to ~&#x2F;config, which actually holds all my config, conveniently a git repository in itself for easy portability and tracking.
评论 #32429470 未加载
评论 #32430134 未加载
评论 #32429525 未加载
评论 #32429383 未加载
评论 #32430130 未加载
评论 #32430832 未加载
评论 #32429882 未加载
评论 #32430186 未加载
评论 #32431685 未加载
评论 #32430171 未加载
评论 #32430156 未加载
评论 #32431134 未加载
评论 #32429293 未加载
评论 #32434350 未加载
评论 #32430483 未加载
评论 #32430268 未加载
评论 #32431323 未加载
BrainVirus将近 3 年前
Most people seem to interpret this as &quot;don&#x27;t hide things&quot;.<p>I interpret this as &quot;file systems need to have a flexible metadata mechanism instead of ad-hoc hacks&quot;. Of course, at this point in time no such thing will happen, because it&#x27;s easier to invent 100 new databases than change some assumptions about our core architecture.
评论 #32429464 未加载
评论 #32431736 未加载
评论 #32429272 未加载
评论 #32431607 未加载
评论 #32429374 未加载
swellguy将近 3 年前
He&#x27;s probably just ignorant of how bad things can get. Hidden files in a home directory is a lot better than what other operating systems came up with (random directories and the dreaded registry). I&#x27;d call it a win - the search over a home directory inode is not going to bother anyone either way.
kgeist将近 3 年前
I don&#x27;t understand how skipping an entry by comparing it with strcmp(name, &quot;.&quot;) == 0 turned into name[0] == &#x27;.&#x27;<p>Is it what really happened (lots of programmers, by mistake, wrote a comparison function which is just plain wrong), or Rob Pike is conjecturing?
评论 #32428758 未加载
评论 #32428954 未加载
评论 #32429328 未加载
评论 #32433045 未加载
评论 #32428724 未加载
评论 #32428684 未加载
heikkilevanto将近 3 年前
Dotfiles are useful, not only in the $HOME directory, but in every project that has a .git directory, and many other ways. Maybe it was a design accident, but it has got stuck, and many old greybeards like me are used to it, and find good use of it.
kazinator将近 3 年前
This is reminiscent of John MacCarthy pooping on NIL.<p>&quot;The unexpected appearance of an interpreter tended to freeze the form of the language, and some of the decisions made rather lightheartedly for the ``Recursive functions ...&#x27;&#x27; paper later proved unfortunate. These included the COND notation for conditional expressions which leads to an unnecessary depth of parentheses, and the use of the number zero to denote the empty list NIL and the truth value false. Besides encouraging pornographic programming, giving a special interpretation to the address 0 has caused difficulties in all subsequent implementations. &quot; (History of Lisp, 1979)
评论 #32431475 未加载
alpaca128将近 3 年前
&gt; my home directory has about a hundred dot files [...]. Every file name evaluation that goes through my home directory is slowed down by this accumulated sludge.<p>Nothing against software efficiency, but those hundred loop iterations checking a string aren&#x27;t going to be the big time-waster of your daily life.
winstonewert将近 3 年前
&gt; when the file system became hierarchical (it had a very different structure early on).<p>This leaves me to wonder, what was the structure early on?
评论 #32431668 未加载
评论 #32429827 未加载
评论 #32429962 未加载
throw7将近 3 年前
Don&#x27;t worry Rob. Freedesktop.org learned and spammed my home dir with Desktop&#x2F;Document&#x2F;Downloads&#x2F;Music&#x2F;etc&#x2F;etc&#x2F;etc...
评论 #32429074 未加载
评论 #32428671 未加载
评论 #32430188 未加载
评论 #32430074 未加载
评论 #32428617 未加载
评论 #32431332 未加载
im3w1l将近 3 年前
A long time ago I liked listening to original soundtracks for games. Winamp had a plugin that would play .psf (et al) files. There were files that contained the extracted code from games for playing the music. The plugin had a tiny builtin emulator that could run the relevant parts. No graphics or input I suppose.<p>One soundtrack I really liked was .hack, including the leading dot. Given that &quot;hack&quot; part and the overall theme of the games I assume the initial dot was quite intended. But what the creators could not have foreseen was that their soundtrack was missing from the majority of psf mirrors (but some had it obviously). I guess some part of some stack ignored dot-prefixed files when doing the mirroring.<p>Anyway, although I&#x27;m usually opposed to inband signalling, I am a fan of dot-prefix for hiding. Filenames already have so many special corner cases that you would have to treat them very carefully even without this one. The fact that it is embedded in the name means that any system can roundtrip hiddenness - something that cannot be said for metadata.
p4bl0将近 3 年前
All my important dotfiles are symlinks to ~&#x2F;local&#x2F;etc, which is versioned.<p><pre><code> $ ls -R1 local&#x2F;etc local&#x2F;etc: bash_aliases bashrc gitconfig inputrc nanorc ocamlinit ssh unison XCompose local&#x2F;etc&#x2F;ssh: config local&#x2F;etc&#x2F;unison: backup.prf</code></pre>
vrnvu将近 3 年前
I got me a copy of The Unix Programming Environment (1984) by Pike and Kernighan last year. It has plenty of hidden small design gems or anecdotes like this one. For example, why files don&#x27;t need a \EOF char, it&#x27;s implicit when you don&#x27;t read more bytes the you have reached the end of a file...<p>Unix design was about making things work (1) and simple (2).
评论 #32429623 未加载
评论 #32429633 未加载
hbn将近 3 年前
That&#x27;s an interesting history lesson! I always assumed hidden dotfiles was a conscious design decision.
评论 #32431754 未加载
transfire将近 3 年前
100%<p>I’m on the verge of abandoning the home directory. I’ll put My files elsewhere and leave home to the apps.<p>I thought XDG would surely solve this problem but it’s painfully clear now that most developers just don’t care. `node_modules` and `snap` are good cases in point. They didn’t even bother hiding them! LOL
labrador将近 3 年前
I feel consternation about symlinks on Windows. I find them extremely useful, but you never know which program is going to ignore them and which program is going to follow them. They&#x27;re inconsistent. Plus you can&#x27;t tell by looking at files if they are symlinks or not because they have the same icon as shortcuts.<p>I recently managed to crash Visual Studio 2022 because I had a symlink to a drive with a hidden $RECYCLE_BIN on it.<p>If you copy files in Windows the system will copy the contents of symlinks, however many backup programs will not follow symlinks.
croes将近 3 年前
&gt;I&#x27;m pretty sure the concept of a hidden file was an unintended consequence. It was certainly a mistake.<p>So it&#x27;s just an assumption and so the title is misleading
codedokode将近 3 年前
Adding . and .. was a mistake by itself. I never needed them, but always had to write conditions to skip them when traversing the file system.<p>Also, dotfiles don&#x27;t work well with masks because `*` doesn&#x27;t match dot-files, and `.*` match all dotfiles including . and .. which causes many programs to fall into endless recursion (for example, `du -sh .*`).<p>Everything related to dotfiles in Linux is done wrong.
评论 #32431495 未加载
jph将近 3 年前
One way to make your config files more visible:<p><pre><code> mv &quot;$HOME&#x2F;.config&quot; &quot;$HOME&#x2F;config&quot; ln -sfn &quot;$HOME&#x2F;config&quot; &quot;$HOME&#x2F;.config&quot; </code></pre> If you want to move and link files that you want to make visible:<p><pre><code> mv &quot;$HOME&#x2F;.foo&quot; &quot;$HOME&#x2F;config&#x2F;foo&quot; ln -sfn &quot;$HOME&#x2F;config&#x2F;foo&quot; &quot;$HOME&#x2F;.foo&quot; </code></pre> If you want, you can set a custom location in your system file `&#x2F;etc&#x2F;profile` or your user file `~&#x2F;.profile`, or `~&#x2F;.bashrc` or `~&#x2F;.zshenv` etc.<p><pre><code> export XDG_CONFIG_HOME=&quot;$HOME&#x2F;config&quot; </code></pre> Helpful links for XDG:<p><a href="https:&#x2F;&#x2F;specifications.freedesktop.org&#x2F;basedir-spec&#x2F;basedir-spec-latest.html" rel="nofollow">https:&#x2F;&#x2F;specifications.freedesktop.org&#x2F;basedir-spec&#x2F;basedir-...</a><p><a href="https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;title&#x2F;XDG_user_directories" rel="nofollow">https:&#x2F;&#x2F;wiki.archlinux.org&#x2F;title&#x2F;XDG_user_directories</a>
评论 #32429036 未加载
评论 #32429277 未加载
mikl将近 3 年前
I agree that it’s annoying that so much junk accumulates in the root of your home dir.<p>But any consumer-facing OS will need some sort of mechanism of hiding&#x2F;protecting configuration files&#x2F;logs&#x2F;etc. from deletion by clueless users, like how macOS has started hiding ~&#x2F;Library by default.
评论 #32430475 未加载
danieldevries将近 3 年前
To some degree this is solved when using stow and a dedicated ~&#x2F;dotfiles directory. No need to dig around in ~&#x2F;.config<p>But I agree with Pike. ls -a in the home sir, becomes an unorganized mess with all those apps that don&#x27;t use the xdg default .config folder.
ggm将近 3 年前
I find the best way to read a Pike statement is to take it as a challenge to your own strongly held belief. I like .dotfiles behaviour and ls -a does not distress me. But, he makes a case it was not deliberate and probably less beneficial than we think.<p>So I look at that as a reframing: do I have a good rebuttal? No. I have my own muscle memory and comfort factor, but that&#x27;s all. How would I think if dotfile hiding didn&#x27;t happen?<p>Hiding . &amp; .. is arguably as silly. It&#x27;s not like they can ever not exist but why hide them?
csydas将近 3 年前
Maybe a dumb question but why do so many apps rely on dotfiles when &#x2F;etc exists? I&#x27;m not making a judgement, this is an earnest question as even though it&#x27;s meant for system config files, is there any reason that all app configurations shouldn&#x27;t live there?<p>If not in &#x2F;etc, then at least &#x2F;usr&#x2F;etc? I&#x27;m sure there is some historical reason but some brief searching and I&#x27;ve not really come up with why dotfiles everywhere are preferable to a centralized configuration directory.
评论 #32429741 未加载
评论 #32429616 未加载
评论 #32429651 未加载
评论 #32429624 未加载
jxy将近 3 年前
The second comment there has its merit in UNIX. However, it is moot with namespace in Plan 9. You can have different versions of the same directory structure, per process.
评论 #32432892 未加载
Night_Thastus将近 3 年前
<i>That&#x27;s</i> why some files like gitignore and clang-format start with a dot? Some old way of hiding the file?<p>How bizarre. I had no idea it was actually related to the . and .. files.
评论 #32428897 未加载
评论 #32429900 未加载
cvccvroomvroom将近 3 年前
Dotfile synchronization is a necessary evil. At work, we have a dotfile synchronization system that contains an infrastructure-level yml file of what to save, what are history files, and what to exclude. Every time a modification is made, it saves a revision. You can have multiple dotfile environments also that completely swaps them out. On the work laptop, I have google drive saving a .dotfiles dir with symlinks into them.
lofatdairy将近 3 年前
&gt;I was wondering why this post had so many comments. Then I found out it was posted on proggit&#x2F;HN. The discussions there were hardly interesting, however.<p>For the curious (was a bit annoying to find since gplus is down now and all links redirect to a different subdomain):<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4331855" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4331855</a>
jzelinskie将近 3 年前
Haha, the first comment is of me throwing shade on HN, oh geez. Now I&#x27;m curious to read the old HN thread that I thought was so disappointing: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4331855" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=4331855</a>
评论 #32428763 未加载
andix将近 3 年前
Dot files are much better than hidden files on Windows (and before DOS). There you need additional attributes to hide files.<p>And hidden files seem to be an important thing. Some things you need to hide from the end user.
评论 #32436292 未加载
unixbane将近 3 年前
this post is a good example of how un*x hippies with their fried brains from too much drugs* realize one unit of common sense after aeons of contemplation. just like with generics in go. in fact, go itself is just decades of C users very slowly conceding to the idea of basic hygiene. it took them decades to come up with something which is essentially just what was already available in the 90s (pascal, fortran, ada, basic, later java 1.2 or so which also had green threads), but with stuff done a certain way so the boomers can be like &quot;oh see, we did this minor syntactic change THIS way, checkmate, pascal&quot;), in other words they want to have their say in everything<p>* im not joking, this is what un*x culture appears to essentially boil down to. boomers were all hippies in the 70s despite presenting themselves as &quot;austere&quot; and &quot;mature&quot; &quot;wise&quot; individuals now, which had the unfortunate side effect of too much drugs. further research is needed to clarify whether brain damage is caused by drugs or un*x<p>any encoding in file names at all is a mistake. this includes character encodings too, which may sound like a non-sequitur but its not. in fact, files should only have unique identities, not names. names should be metadata. folder hierarchy should just be a user defined data structure that can reference these said &quot;files&quot;. anyone who tries developing their own OS without copying extremely idiosyncratic un*x ideas and without being bogged down by the overhead of assembly language or C quickly learns this. an example of youngins discovering this is IPFS (and subsequently implementing it on top of broken un*x)
评论 #32431453 未加载
评论 #32430154 未加载
Rackedup将近 3 年前
just put them all in ~&#x2F;configs ... many apps still pollute ~&#x2F;
hk1337将近 3 年前
A happy little accident
smm11将近 3 年前
However Apple does it is best.
esoterae将近 3 年前
alias ls=&#x27;ls -a&#x27;
评论 #32429101 未加载
评论 #32429422 未加载
noncoml将近 3 年前
First of all, “A lot of other lazy programmers”. That’s cringe. I don’t care who you are, that’s not a way to talk.<p>Secondly, I think we have all been there. We introduce a bug in an interface&#x2F;API but then the users of it start depending on this behaviour and before you know it it’s a feature and it’s impossible to fix without breaking the world.
评论 #32430312 未加载
评论 #32430314 未加载
评论 #32432252 未加载
评论 #32431346 未加载