Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

About 20 or so years ago, I have come across a configuration pattern that could be arguably called "Level 0". It was configuration by file existence. The file itself would be typically empty. So no parsing, syntax, or schema involved. For example, if the file /opt/foo/foo.txt exists, the software does one thing but if it is missing the software does another thing. So effectively, the existence of the file serves as a boolean configuration flag.


A top-level /AppleInternal/ directory on macOS, even if empty, will enable certain features in Apple developer tools.


I've observed similar things to happen in other tools too - third-party tools that will list a certain set of file formats by default, and enable Autodesk formats if C:/Autodesk is present.

It seems to be most common in systems that cross major business domains (or come from completely separate companies). If you could just add an entry to the featureful, versioned, controlled config file then you'd do that, but if you can't developers frequently resort to the "does this path name resolve" heuristic.


A number of traditional unix utilities change their behavior based on what their name is. /bin/test and /bin/[ come to mind. but I just checked and a quick survey of openbsd finds.

    eject mt
    [ test
    chgrp chmod
    cksum md5 sha1 sha256 sha512
    cpio pax tar
    ksh rksh sh
taken to it's logical extreme you end up with somthing like crunchgen https://man.openbsd.org/crunchgen which merges many independent programs into one and select which one to run based on the name.

And I am guilty of abusing symbolic links as a simple single value key value store. It turns out the link does not need to point to anything and using readlink(1) was easier than parsing a file.


ssh and rsh used to cause you to rsh/ssh to the name of the file...

so I had, in my home directory

~me/bin/snoopy

and if I wanted to log into snoopy, I'd just type

$ snoopy

and it'd rsh me into snoopy.

Hilarity was the day when someone ran

  cd /export/home && for user in * ; do chown -R $user:users ; done
(note the lack of the -h flag, which causes the ownership of the symbolic link instead of the reference of the symbolic link to be chowned)


Postgres does that with standby.signal and recovery.signal files.

https://www.postgresql.org/docs/current/runtime-config-wal.h...


This gives me an idea - store small integer parameters (<= 511) as file permissions (r/w/exe for user/group/other) on an empty file.


Larger integers can go into UID:GID values.


Similar behavior in the s6 overlay framework for containers. Some files do things just by existing IIRC


I use this approach for testing conditional logic in shell scripts sometimes.


That's just cramming a flag into the file system.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: