Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux

by jakobi (Pilgrim)
on Oct 06, 2009 at 18:25 UTC ( [id://799552]=note: print w/replies, xml ) Need Help??


in reply to Re: POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux
in thread POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux

Alexander talked enough about symlinks that I want to add this caution on both symlinks and hardlinks to the thread:

If you write to existing files other than append-without-backup, and there's the tiniest risk of a user trying to symlink or hardlink that file: explicitely specify how you write out the file. Funny things happen: E.g. sed -i.bak or perl i.bak and that patch on Fedora recently being removed: changing sed's semantics wrt symlinks and surprising everyone.

date > 1; ln -s 1 2; perl -i.bak -lpe '' 2; ls -l [12]* # enjoy

So at the very least, document how and when you're breaking symlinks or hardlinks on writing. Or not breaking them. Which might be just as bad.

cu
Peter

Footnote: -d _ reuses the previous stat, as Alexander writes, just -d does a new stat using $_. So this an an example of terseness being possibly more costly in both debugging time and runtime :).

  • Comment on Re^2: POSIX::S_ISDIR() with $stat->mode values from Windows vs. Linux
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://799552]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (10)
As of 2024-04-23 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found