Re: Naming convention of bash script filenames

2010-07-12 Thread Andreas Schwab
Bob Proulx  writes:

> For an executable script I use no suffix at all.  It matters not if
> the script is a bash script, sh, ksh, perl, ruby, or whatever.

Assuming it uses the appropriate shebang.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



Re: How to run something before invoking the inputted command?

2010-07-12 Thread Greg Wooledge
On Sat, Jul 10, 2010 at 11:22:27AM +0800, Clark J. Wang wrote:
> For example, in the interactive shell, I want to track the time when every
> inputted command is invoked. So I want to run a `date' command before
> actually invoking the inputted command. For now I have to do like this:
> 
> $ date; command1
> $ date; command2

You could set a DEBUG trap.

trap 'date +%H:%M:%S' DEBUG

> On Sat, Jul 10, 2010 at 11:30 AM, Eric Blake  wrote:
> > Not quite before the command, but it is very easy to include $(date) as
> > part of PS1 to have a timestamp listed in the prompt that is printed
> > after every command.

On Sat, Jul 10, 2010 at 11:54:05AM +0800, Clark J. Wang wrote:
> Yes, timestamp in PS1 is fine for after-command purposes. And actually I use
> the PROMPT_COMMAND var for that.

unset PROMPT_COMMAND
PS1='$(date +%H:%M:%S)|\h:\w\$ '

Personally I've never found any use for PROMPT_COMMAND.  It seems klunky
and awkward.



Re: How to run something before invoking the inputted command?

2010-07-12 Thread Dave Rutherford
On Mon, Jul 12, 2010 at 08:16, Greg Wooledge  wrote:
>> On Sat, Jul 10, 2010 at 11:30 AM, Eric Blake  wrote:
>> > Not quite before the command, but it is very easy to include $(date) as
>> > part of PS1 to have a timestamp listed in the prompt that is printed
>> > after every command.
>
> On Sat, Jul 10, 2010 at 11:54:05AM +0800, Clark J. Wang wrote:
>> Yes, timestamp in PS1 is fine for after-command purposes. And actually I use
>> the PROMPT_COMMAND var for that.
>
> unset PROMPT_COMMAND
> PS1='$(date +%H:%M:%S)|\h:\w\$ '

Why not just use the \t escape in PS1? Or, if you want other
arguments to strftime, you could write \D{%H:%M:%S}.



Re: How to run something before invoking the inputted command?

2010-07-12 Thread Andreas Schwab
"Clark J. Wang"  writes:

> For example, in the interactive shell, I want to track the time when every
> inputted command is invoked. So I want to run a `date' command before
> actually invoking the inputted command. For now I have to do like this:
>
> $ date; command1
> $ date; command2
>
> Is there an easy way to do that?

You can get from the history output, if you set HISTTIMEFORMAT.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



how to limit autofill of executables in 'cygwin-bash' to a list of 'extensions'

2010-07-12 Thread Linda Walsh

I have a long standing problem under cygwin in that when I type
a prefix of 1 or more executables and hit the expand character (ESC),
it lists out all the DLL's in my system path.

I NEVER want to execute libraries directly.  Many or most are
not executables -- yet bash lists them.  In Windows, the
'exec' bit doesn't mean it is an executable -- it means
it is executable code that can be loaded into an executable
segment of memory.  Files that don't have that bit set get
loaded into memory (on properly configured systems) that
has a "NX:Not eXecutable" bit set, that disallows execution.

Anyway -- it's more of an OS thing than a strictly a user
thing -- and Windows uses a registry String value:
[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session 
Manager\Environment\PathExt]
(example value = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC")
(
 cygwin bash on win64:
#> 
PATHEXT="$(<'/proc/registry64/HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Control/Session 
Manager/Environment/PATHEXT')"
)

to control what files are executable. 


Not saying this is a bash bug -- as it's really more of how bash
should be configured on windows platforms (I suppose the same would
be true for any MING versions of bash as well), but how can bash
be setup to only display the executables appropriate for the 
given OS?


Thanks!
Linda




Re: how to limit autofill of executables in 'cygwin-bash' to a list of 'extensions'

2010-07-12 Thread Chet Ramey
On 7/12/10 6:18 PM, Linda Walsh wrote:
> I have a long standing problem under cygwin in that when I type
> a prefix of 1 or more executables and hit the expand character (ESC),
> it lists out all the DLL's in my system path.
> 
> I NEVER want to execute libraries directly.  Many or most are
> not executables -- yet bash lists them.  In Windows, the
> 'exec' bit doesn't mean it is an executable -- it means
> it is executable code that can be loaded into an executable
> segment of memory.  Files that don't have that bit set get
> loaded into memory (on properly configured systems) that
> has a "NX:Not eXecutable" bit set, that disallows execution.
> 
> Anyway -- it's more of an OS thing than a strictly a user
> thing -- and Windows uses a registry String value:
> [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session
> Manager\Environment\PathExt]
> (example value = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC")
> (
>  cygwin bash on win64:
> #>
> PATHEXT="$(<'/proc/registry64/HKEY_LOCAL_MACHINE/SYSTEM/ControlSet001/Control/Session
> Manager/Environment/PATHEXT')"
> )
> 
> to control what files are executable.
> Not saying this is a bash bug -- as it's really more of how bash
> should be configured on windows platforms (I suppose the same would
> be true for any MING versions of bash as well), but how can bash
> be setup to only display the executables appropriate for the given OS?

You have to modify the source.  findcmd.c:executable_file and
findcmd.c:file_status are the functions to change.  Bash just uses
the standard exec bit.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Re: How to run something before invoking the inputted command?

2010-07-12 Thread Clark J. Wang
>
> Personally I've never found any use for PROMPT_COMMAND.  It seems klunky
> and awkward.
>

My PS1 depends much on PROMPT_COMMAND. For example, my PROMPT_COMMAND will
trim very long $PWD to a shorter one (depends on the window size of current
terminal):

[r...@server ~/directory/lng/very/a/is/this] #>
[r...@server ~/.../very/a/is/this] #

Bash 4.0 introduces a new similar feature via var PROMPT_DIRTRIM.

-Clark