f



'file mkdir' doesn't fail

Hi all,

from the 'file mkdir' man page:

  If an  existing  directory  is  specified,
  then  no  action is taken and no error is returned.

Why is this so? AFAIK mkdir is guaranteed to be atomic and
exclusive even for root, which makes it ideal to create lock
files (dirs). Shouldn't 'file mkdir dirname' throw an error
when 'dirname' exists?

Best regards

Ulrich

-- 

For those of you who don't get this e-mail, let me know and I'll re-send it.

0
10/21/2003 4:31:15 PM
comp.lang.tcl 23429 articles. 2 followers. Post Follow

6 Replies
815 Views

Similar Articles

[PageSpeed] 17

Ulrich Schoebel <ulrich.schoebel@tclers.tk> wrote:
# Hi all,
# 
# from the 'file mkdir' man page:
# 
#   If an  existing  directory  is  specified,
#   then  no  action is taken and no error is returned.
# 
# Why is this so? AFAIK mkdir is guaranteed to be atomic and
# exclusive even for root, which makes it ideal to create lock
# files (dirs). Shouldn't 'file mkdir dirname' throw an error
# when 'dirname' exists?

Because most people use mkdir to make directories rather than locks?
I want the directory to exist when the command completes. Why bitch
and whine if the postcondition is also the precondition and the
command doesn't have to do anything?

If you want to make a lock, why not just create a lock command? And then
you can hide the implementation, whether a mkdir or open O_EXCL or fcntl
locks (unix) or open read exclusive (mac os 9) or whatever else delights
you. Those who want a lock now have an explicit lock command that clear
syntax and semantics, and those who want to create a directory have their
command with clear syntax and semantics.

--
Derk Gwen http://derkgwen.250free.com/html/index.html
So....that would make Bethany part black?
0
derkgwen (343)
10/21/2003 6:16:38 PM
Derk Gwen <derkgwen@HotPOP.com> wrote:
>
>  I want the directory to exist when the command completes. Why bitch
>  and whine if the postcondition is also the precondition and the
>  command doesn't have to do anything?
>

 However, if the directory already existed, then permissions may be
incompatible. Maybe the directory was created by a different user,
and you will not have write privilege. Therefore it would make sense
for "file mkdir" to throw an error.

	Frank


-- 
Frank Pilhofer  ...........................................  fp@fpx.de
War is what happens when arms are used instead of heads! -A. E. Neuman
0
fp (16)
10/27/2003 12:46:18 AM
Frank Pilhofer wrote:
> Derk Gwen <derkgwen@HotPOP.com> wrote:
>> I want the directory to exist when the command completes. Why bitch
>> and whine if the postcondition is also the precondition and the
>> command doesn't have to do anything?

>  However, if the directory already existed, then permissions may be
> incompatible. Maybe the directory was created by a different user,
> and you will not have write privilege. Therefore it would make sense
> for "file mkdir" to throw an error.

An interesting reason not to have it fail, but that's not the way
that 'file mkdir' was designed.  In any case, you can check for
whichever situation with the other 'file' commands.

-- 
     Jeff Hobbs                     The Tcl Guy
     Senior Developer               http://www.ActiveState.com/
         Tcl Support and Productivity Solutions

0
jeffh (1291)
10/27/2003 1:51:51 AM

Jeff Hobbs wrote:
> Frank Pilhofer wrote:
> 
>> Derk Gwen <derkgwen@HotPOP.com> wrote:
>>
>>> I want the directory to exist when the command completes. Why bitch
>>> and whine if the postcondition is also the precondition and the
>>> command doesn't have to do anything?
> 
> 
>>  However, if the directory already existed, then permissions may be
>> incompatible. Maybe the directory was created by a different user,
>> and you will not have write privilege. Therefore it would make sense
>> for "file mkdir" to throw an error.
> 
> 
> An interesting reason not to have it fail, but that's not the way
> that 'file mkdir' was designed.  In any case, you can check for
> whichever situation with the other 'file' commands.
> 
No, you can't, if want to use 'file mkdir' to generate a semaphore
directory. It would leave a time slice where another process can
come in.

-- 

For those of you who don't get this e-mail, let me know and I'll re-send it.

0
10/27/2003 9:37:41 AM
Ulrich Schoebel wrote:
>>>> I want the directory to exist when the command completes. Why bitch
>>>> and whine if the postcondition is also the precondition and the
>>>> command doesn't have to do anything?

>>>  However, if the directory already existed, then permissions may be
>>> incompatible. Maybe the directory was created by a different user,
>>> and you will not have write privilege. Therefore it would make sense
>>> for "file mkdir" to throw an error.

>> An interesting reason not to have it fail, but that's not the way
>> that 'file mkdir' was designed.  In any case, you can check for
>> whichever situation with the other 'file' commands.

> No, you can't, if want to use 'file mkdir' to generate a semaphore
> directory. It would leave a time slice where another process can
> come in.

Semaphore directory?  That's a highly suspicious thing to rely on
x-platform anyway.  Look on the wiki about the vaguaries of x-plat
locking.  The solutions using files aren't bad ... I guess the same
could apply to directories.

-- 
     Jeff Hobbs                     The Tcl Guy
     Senior Developer               http://www.ActiveState.com/
         Tcl Support and Productivity Solutions

0
jeffh (1291)
10/27/2003 4:33:24 PM
According to Jeff Hobbs  <jeffh@activestate.com>:
:Ulrich Schoebel wrote:
:> No, you can't, if want to use 'file mkdir' to generate a semaphore
:> directory. It would leave a time slice where another process can
:> come in.
:
:Semaphore directory?  That's a highly suspicious thing to rely on
:x-platform anyway.  

Actually, if the program might run on NFS, then the problems can occur
even without cross platform coming into play.

 


-- 
<URL: http://wiki.tcl.tk/ > In God we trust.
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.
<URL: mailto:lvirden@yahoo.com > <URL: http://www.purl.org/NET/lvirden/ >
0
lvirden272 (610)
10/28/2003 12:47:21 PM
Reply:

Similar Artilces:

'is not' or '!='
A newbie question to you; what is the difference between statements like: if x is not None: and if x != None: Without any context, which one should be preferred? IMHO, the latter is more readable. On 2014-08-18 21:35, ElChino wrote: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: > > Without any context, which one should be preferred? > IMHO, the latter is more readable. > "x == y" tells you whether x and y refer to objects that are equal. "x is y" tells you whether x and y actually refer to the same object. In the case of singletons like None (there's only one None object), it's better to use "is". "ElChino" <elchino@cnn.cn>: > A newbie question to you; what is the difference between statements > like: > if x is not None: > and > if x != None: Do the following: take two $10 bills. Hold one bill in the left hand, hold the other bill in the right hand. Now, the bill in the left hand "is not" the bill in the right hand. However, the bill in the left hand "==" the bill in the right hand. > Without any context, which one should be preferred? > IMHO, the latter is more readable. In almost all cases, both tests would result in the same behavior. However, the "is not" test is conceptually the correct one since you want...

'^=' and '~='?
Hello, What is the difference between '^=' and '~='? Thanks, Duckhye ...

Removing the letters 't' 'i' 'x' and 'y'
Im having trouble with figuring out how to write a function which will remove the letters 't' 'i' 'x' and 'y' from any input string in matlab. for example modstr(pixy) should result in ans = 'p' or modstr(picture) should result in ans = 'pcure' if anyone could offer any help or hints i would really appreciate it. Thank You >> modstr=@(s) s(~ismember(s,'tixy')) modstr = @(s)s(~ismember(s,'tixy')) >> modstr('picture') ans = pcure % Bruno ...

wxIE doesn't handle 'enter', 'delete' key, 'control-c' 'control-v' properly
I built the wxIE project from: http://sourceforge.net/projects/wxactivex Which is great, but I can't use the 'delete' key, nor 'enter', nor control-c/control-v in the IE window. Using SPY++ and stepping through the code I see that the keys are being sent to the IE Window so I'm lost as to how to make it work. Has anyone seen oddities like this using wxActiveX? Everything looks right so it's very frustrating... Joe -- View this message in context: http://www.nabble.com/wxIE-doesn%27t-handle-%27enter%27%2C-%27delete%27-key%2C-%27control-c%27-%27co...

'''''''''''''The Running Update/Append Queries Using VBA code Ordeal'''''''''''''' #2
Hi, Thanks for ur help there HJ. I know how to do the tasks you specified there. I would like for the update query to use field values from some of the fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, DateTo. My problem is that an append/update query can't find the values in the open Form (frmInvoices) when I specify them as; [Forms]![frmInvoices]![InvoiceNumber] a select query has no problem finding the field values on a form. please help. Aaron Hi Aaron, Could you post the entire code that you are having trouble with? Now it is not possible to see what goes wrong. HJ "Aaron" <aaron@rapid-motion.co.uk> wrote in message news:260d7f40.0408120245.2f3d01f8@posting.google.com... > Hi, > > Thanks for ur help there HJ. > > I know how to do the tasks you specified there. > > I would like for the update query to use field values from some of the > fields on the form (frmInvoices) such as InvoiceNumber, DateFrom, > DateTo. My problem is that an append/update query can't find the > values in the open Form (frmInvoices) when I specify them as; > > [Forms]![frmInvoices]![InvoiceNumber] > > a select query has no problem finding the field values on a form. > > please help. > > Aaron First off, if you are not always using all the parameters specified in your form, then you have to add parameters to your query on the fly. Also, you can't just do something like qdf.SQL = "SE...

if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.') Any shorter ?
Hi, there. =20 I'm just curious if it ever dawned on anybody how to abbreviate this line : if str_mo not in ('','.') and str_da not in ('','.') and str_yy not in ('','.')=20 =20 Igor Kurbeko Clinical Programmer Analyst 678 336 4328 ikurbeko@atherogenics.com =20 no brain no pain =20 how about: if not (str_mo in ('','.') or str_da in ('','.') or str_yy in ('','.')) OR if not (missing(str_mo) or missing(str_da) or missing(str_yy)) Eric On 22 Oct 03 21:13:37 GMT, ikurbeko@ATHER...

__getattribute__ doesn't work on 'type' type for '__class__'
I'm running this version of Python: Python 2.4.3 (#1, May 18 2006, 07:40:45) [GCC 3.3.3 (cygwin special)] on cygwin I read in the documentation that these two expressions are interchangeable: x.__getattribute__('name') <==> x.name From "pydoc __getattribute__": ---8<--- Help on method-wrapper object: __getattribute__ = class method-wrapper(object) | Methods defined here: | | __call__(...) | x.__call__(...) <==> x(...) | | __getattribute__(...) | x.__getattribute__('name') <==> x.name --->8--- Yet when I...

'cat file' but only if 'file' exist
I'm trying to run 'cat *.x' only if *.x files exist. What is the cleanest way of doing this? I'm doing it by shopt -s nullglob for i in *.x; do cat $i; done but this is aweful typing. -- William Park, Open Geometry Consulting, <opengeometry@yahoo.ca> No, I will not fix your computer! I'll reformat your harddisk, though. On 2004-06-09, William Park wrote: > I'm trying to run 'cat *.x' only if *.x files exist. What is the > cleanest way of doing this? I'm doing it by > shopt -s nullglob > for i in *.x; do cat $i; done > but this is aweful typing. set -- *.x [ -f "$1" ] && cat -- *.x -- Chris F.A. Johnson http://cfaj.freeshell.org/shell =================================================================== My code (if any) in this post is copyright 2004, Chris F.A. Johnson and may be copied under the terms of the GNU General Public License 2004-06-9, 06:26(+00), William Park: > I'm trying to run 'cat *.x' only if *.x files exist. What is the > cleanest way of doing this? I'm doing it by > shopt -s nullglob > for i in *.x; do cat $i; done > but this is aweful typing. zsh -c 'cat ./*.x' With bash: shopt -s nullglob files=(./*.x) if (( ${#files[@]} > 0 )); then cat "${files[@]}" else printf >&2 '%s\n' "${0##*/}: no *.x files" false fi You could also do: c...

A function with 'and' , 'not' , 'null' , 'car' and 'cdr'
What's this ? (defun enigma (x) (and (not (null x)) (or (null (car x)) (enigma (cdr x))))) "I suppose I should learn Lisp, but it seems so foreign." - Paul Graham, Nov 1983 On Wed, Oct 07 2015, CAI GENGYANG wrote: > What's this ? > > > (defun enigma (x) > (and (not (null x)) > (or (null (car x)) > (enigma (cdr x))))) Bad taste? It returns T if the list X contains nil as an element. It would be clearer to write (some #'null x). Helmut CAI GENGYANG ...

web('file', 'filename' '-browser') not working
Hello, I'm working on a project involving Matlab and a nice flashy GUI. To call help files, I do: web('file', 'help.html' '-browser'); On my computer, this works. After compiling it, it works. If I manage to get the current directory wrong, somehow, the browser attempts to go to www.help.com, rather than put up an error. So far so good, except when the file isn't there, which I'm ignoring for the moment. However, when I run the program on other computers (I compile the program first), it always goes to www.help.com, no matter what the pwd says, or where I put help.html. This seems to happen on about half of the other computers I try it on. Any ideas? I had thought it was just path mixups but putting 'pwd' in the appropriate places seems to indicate nothing is amiss. I do not want to use explicit path names, (ie 'file:///c:/stuff/help.html' syntax) as this program is meant for some distribution and I can't guarantee that people will always have it running from the same location. Thank you in advance, --Anne I finally did a = sprintf('file:///%shelp.html#%s', pwd, section); web('file', a, '-browser'); I discovered that the file:/// syntax does not require paths to be deliminated by '/' but can use '\' unlike what I had thought. I read a bug report that using the internal web browser crashes when using compiled code. However, a similar crash happens for me when using R2006a....

unix2dos ( tr '\12' '\15\12' ) doesn't run
Hi, m3vmsa3.caddebug /tmp > tr '\12' '\15\12' < foo > foo.tr m3vmsa3.caddebug /tmp > od -t c foo 0000000 o n e \n t w o \n t h r e e \n 0000016 m3vmsa3.caddebug /tmp > od -t c foo.tr 0000000 o n e \r t w o \r t h r e e \r 0000016 Why does tr not add '\12' to foo.tr? Thanks in advance, Jose Luis On Tue, 18 Dec 2007 04:08:26 -0800 (PST), Jose Luis wrote: > > Hi, > > m3vmsa3.caddebug /tmp > tr '\12' '\15\12' < foo > foo.tr > m3vmsa3.caddebug /tmp > od -t c ...

Array#uniq
I am confused about "Array#uniq". In http://groups.google.com/group/comp.lang.ruby/msg/e57b80fbcd61aaab it is described, that one has to redefine "eql?" and "hash", if one needs an own "Array#uniq" interpretation. I made tests with the result, that neither "eql?" nor "hash" is called. What went wrong here? >>>>> code >>>>> class String alias :org_hash :hash alias :org_eql? :eql? def hash puts 'String#hash called' self.hash end def eql?(other) puts 'String#...

Bash 'umask' builtin doesn't set 'x' permissions?
I was tinkering around with the Bash builtin command 'umask' (on a Red Hat Linux 9 box) and noticed the following behavior: [bash]$ rm -f ./try; umask 0002; touch try; ls -l try -rw-rw-r-- 1 me me 0 Jul 11 14:49 try [bash]$ umask -S u=rwx,g=rwx,o=rx Note that the 'x' bits are not turned on for the newly created file 'try'. IOW, I expected try's file permissions would be set to "-rwxrwxr-x". Why weren't they? Is this a "Bash thing" or a "Red Hat thing" or other? -- Jim To reply by email,...

Tcl 8.6 unexpected 'file exists'
I have a proc which takes a full path argument for a file. (one of the items returned from a glob) roughly: proc handlefile {path} { #puts stdout [file normalize $path] set fsize [file size $path] #...etc } Strangely... a particular file has problems with the above. The 'file size' call returns: could not read "/usr/local/xxx/www/yyy/Newsletter/050609/~ $sueme220509.htm" no such file or directory The 'file normalize' output is "/usr/local/virtual1/hosting/base/yy/ yyy/yyy/www/Newsletter/050609/~$sueme220509.htm" Both these paths are valid, and equivalent due to some soft symlinking - and both work just fine in an interactive tclsh with 'file size' returning a size and 'file exists' returning 1. The heisenbuggish thing is - that the mere act of using puts to display the normalized path (without actually using the normalized value anywhere); causes the problem to disappear. i.e uncommenting the 2nd line in the proc above causes file size to work as expected. I'm assuming this is a bug - but at this stage I don't know if the ~ or $ characters are relevant or if it just happened to occur on this strangely named file for some other reason. This problem occurs on FreeBSD with a Tcl 8.5.b1 checked out in january - and also with 8.6b1.1 from 2009-06-14 The bug doesn't occur when I use an 8.5a4 tclkit I'll report a bug for it if it turns out to be a new one - but I just thought I'd throw ...

error: expected '=', ',', ';', 'asm' or '__attrib
Hi I'm trying to compile an ADC Driver & come acrosss the following error. I've no experience writing drivers before, and hence have no clue how to fix it. Hope someone out there has encountered the problem & suggesst a fix for the same. The Error is I get is : qadc.c: At top level: qadc.c:97: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'qadc_read' make: *** [qadc.o] Error 1 [root@localhost qadc]# ########################################################################### ADC Driver Code ##...

'!' vs. '.'
Is there an advantage to using the '!' notation to represent form/ control relationships? (eg. Me!text1 vs Me.text1) I am currently using the '.' notation exclusively (for code completion in the VB Editor), but much of the high-quality code that I've seen (in Duane Hookom's Query-by-Form db, for example) uses the other. Here's one opinion for you: http://doc.advisor.com/doc/05352 robert.waters wrote: >Is there an advantage to using the '!' notation to represent form/ >control relationships? (eg. Me!text1 vs Me.text1) > >I am currently using the '.' notation exclusively (for code completion >in the VB Editor), but much of the high-quality code that I've seen >(in Duane Hookom's Query-by-Form db, for example) uses the other. -- HTH - RuralGuy (RG for short) acXP WinXP Pro Please post back to this forum so all may benefit. Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/databases-ms-access/200704/1 Here's my $0.02 worth on this. I tend to copy the notation style and naming conventions that I see being used in the Help files. That would be Me![text1] for a control on a form. I am of the belief that this notation explicitly refers to a control itself rather than a field in the form's recordset. Here's an example: I have a parts inventory app that uses a "Line" code, which is usually a 3-character abbreviation for a brand name, and is the na...

logical to 'on' / 'off'
Hi, is there a function implemented doing this conversion? my Problem is, that I want to use the following code: set(handles.edit_curr_trq_sl,'Enable',get(hObject,'Value')) where get(hObject,'Value') gives the state of a checkbox thank you! function [str]=tf2oo(logic) switch logic case 0 str='off'; case 1 str='on'; end%switch end%function tf2oo() while i do not know a built in function, I use my own:) meisterbartsch wrote: > > > function [str]=tf2oo(logic) > switch logic > case 0 > str='off'; &g...

Difference between 'is' and '=='
Hey guys, this maybe a stupid question, but I can't seem to find the result anywhere online. When is the right time to use 'is' and when should we use '=='? Thanks alot~ mwql: >Hey guys, this maybe a stupid question, but I can't seem to find the >result anywhere online. When is the right time to use 'is' and when >should we use '=='? http://docs.python.org/ref/comparisons.html -- Ren´┐Ż Pijlman mwql wrote: > Hey guys, this maybe a stupid question, but I can't seem to find the > result anywhere online. When is the right time to ...

Does '!=' equivelent to 'is not'
I'm a bit confusing about whether "is not" equivelent to "!=" if a != b: ... if a is not b: ... What's the difference between "is not" and "!=" or they are the same thing? pirata wrote: > I'm a bit confusing about whether "is not" equivelent to "!=" > > if a != b: > ... > > if a is not b: > ... > > > What's the difference between "is not" and "!=" or they are the same thing? No, they are not the same thing. == and != test to see if the *value* of two variables are the same. Like so: >>> a = 'hello world' >>> b = 'hello world' >>> a == b True a and b both have the value of 'hello world', so they are equal is and is not, however, do not test for value equivalence, they test for object identity. In other words, they test to see if the object the two variables reference are the same object in memory, like so: >>> a is b False a and b are assigned to two different objects that happen to have the same value, but nevertheless there are two separate 'hello world' objects in memory, and therefore you cannot say that a *is* b Now look at this: >>> c = d = 'hello world' >>> c == d True >>> c is d True In this case, they are again the same value, but now the is test also shows that they are the same *object* as well, because...

'a'..'z'
Is it possible to achieve something like this? switch (mystring.charAt(0)) { case 'a'..'z': // do something break; } "cruster" <cruster@gmail.com> wrote in message news:1151319731.988814.326200@m73g2000cwd.googlegroups.com... > Is it possible to achieve something like this? > > switch (mystring.charAt(0)) { > case 'a'..'z': > // do something > break; > } > There are times when an if statement may be more appropriate ;) Sorry - java is not VB :) -- LTP :) cruster schreef: > Is it possible to achieve somethi...

'[OFF]' as in 'offensive'???
Hi, given that 'off-topicness' is indicated as '[OT]' and taking a look at those postings that started the threads indicated as '[OFF]' (which may both be seen as being somewhat offensive) may lead to the conclusion that '[OFF]' stands for offensiveness. I don't think that this is the intended meaning so what actually *does* '[OFF]' mean? I never came across that abbreviation before (although I have been around on the USENET for quite some time) but maybe it is worth knowing? Josef 'Jupp' Schugt NOTE: mails >100 KiB ...

replacement for '{' and '}' ?
I am still playing around with what kind of syntax I would like to mark up my documents. Are there equivalent long substitutes for { and } when they are not used to describe arguments to functions? Something like \begin{group} and \end{group}. In other words, if I could force myself to write, say, \begin{group} \it ... \end{group} instead of {\it ... }, then I believe I could identify from the markup context what is an argument that belongs to a just invoked macro and what is text. {Of course, in this context, \textit{...} would be better.} No more ambiguity whether a in \myfunction{a} is an argument or just text. Is there a way to make latex barf when it sees an ordinary '{' in text, rather than \begin{group}, but not barf when I want it (to denote macro arguments)? Regards, /iaw On Aug 16, 6:01=A0pm, "ivo...@gmail.com" <ivo...@gmail.com> wrote: > Is there a way to make latex barf when it sees an ordinary '{' in > text, rather than \begin{group}, but not barf when I want it (to > denote macro arguments)? What do you mean exactly? I don't understand. Do you have in mind your- to-be-new-syntax or just regular latex? Cheers, Tomek ivowel@gmail.com wrote: > I am still playing around with what kind of syntax I would like to > mark up my documents. > > Are there equivalent long substitutes for { and } when they are not > used to describe arguments to functions? Something like \begin{group} > and \end{gr...

Override 'and' and 'or'
Is it possible to override 'and' and/or 'or'? I cannot find a special method for it... __and__ and __rand__ and __or__ and __ror__ are for binary manipulation... any proposals? Have marvelous sunday, Marco Dekker <m.aschwanden@gmail.com> wrote: > Is it possible to override 'and' and/or 'or'? I cannot find a special > method for it... __and__ and __rand__ and __or__ and __ror__ are for > binary manipulation... any proposals? If you want to customize the truth value testing you have to implement __nonzero__ " __nonzero__( self) Call...

Replacing ',' with '.'
Hello, I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method that does this during the import procedure. -Janne Hi, I guess you import the data as text and convert it then to numbers. Try 'strrep' before you convert the text to numbers. Tobias Jake the Snake schrieb: > Hello, > > I have a huge amount of numbers in a .txt file. The numbers are in the form 2,43252e+1. I need to replace the , with . How should I do this? I'd prefer some import method...

Web resources about - 'file mkdir' doesn't fail - comp.lang.tcl

Resources last updated: 3/13/2016 8:32:24 PM