diff --git a/twander.py b/twander.py index 4e30f79..73e6986 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.205 2006/12/18 17:35:09 tundra Exp $" +RCSID = "$Id: twander.py,v 3.206 2006/12/18 22:02:25 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -3572,7 +3572,9 @@ elif (OSPLATFORM == 'win32') or (OSNAME == 'posix'): - usestartdir=False + # Find out if the OS thinks this is an executable file + + executable = os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH) # Apply any relevant association information @@ -3586,27 +3588,40 @@ # association is defined, apply it to everything # except executable files. - if not assocfound and (ASSOCDFLT in UI.Associations) and not (os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH)): + if not assocfound and (ASSOCDFLT in UI.Associations) and not executable: selected = UI.Associations[ASSOCDFLT] assocfound = True - # If there is NOT an association, create absolute path to - # selected command + # In the case of Unix-like OSs, if the file is non-executable + # and has no association, this is an error and needs to + # flagged as such. In Windows, this may- or may-not be an + # error because of Windows own association mechanism. So, we + # pass the request through on Windows and let it handle this + # case. - if not assocfound: - selected = os.path.join(os.path.abspath(UI.CurrentDir), selected) - - # Win32 has a special command interface wherein its internal associations - # are applied. We only invoke command execution this way when twander - # found no associations of its own. - - if OSPLATFORM == 'win32': - usestartdir=True - + if not executable and not assocfound and OSNAME == 'posix': + ErrMsg(eBADEXEC % selected) + # Now execute the command - ExecuteCommand(selected, '', ResolveVars=True, ResolveBuiltIns=True, UseStartDir=usestartdir) + else: + + usestartdir=False + # If there is NOT an association, create absolute path to + # selected command + + if not assocfound: + selected = os.path.join(os.path.abspath(UI.CurrentDir), selected) + + # Win32 has a special command interface wherein its internal associations + # are applied. We only invoke command execution this way when twander + # found no associations of its own. + + if OSPLATFORM == 'win32': + usestartdir=True + + ExecuteCommand(selected, '', ResolveVars=True, ResolveBuiltIns=True, UseStartDir=usestartdir) return 'break'