zsh-users
 help / color / mirror / code / Atom feed
* Autoloaded bash shell scripts treated as zsh
@ 2005-03-07 23:41 zzapper
  2005-03-08  6:05 ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: zzapper @ 2005-03-07 23:41 UTC (permalink / raw)
  To: zsh-users

Hi,
I used a tip from one of the faqs (Peter Stephenson I think) to autoload all my 
zsh shell scripts.

autoload ${fpath[1]}/*(:t)  #autoload all functions in $fpath

As I also use the same directory for my legacy bash scripts, I was unpleasantly 
surprised to find that these scripts had also been autoloaded and were now being 
treated as zsh scripts.

Easy to fix, either I make the scripts zsh compatible or move them elsewhere.

Q1)
But is that expected behaviour (latest zsh on cygwin)?

Q2)
I was surprised to what extent my bash scripts worked as zsh (mostly only 
required the adding of a pre-declaration of any variables), is a reasonable 
proportion of bash available from within zsh?


zzapper

BTW this is posted via http://post.gmane.org/post.php?group=gmane.comp.shells.
zsh.user


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Autoloaded bash shell scripts treated as zsh
  2005-03-07 23:41 Autoloaded bash shell scripts treated as zsh zzapper
@ 2005-03-08  6:05 ` Bart Schaefer
  2005-03-08 10:21   ` zzapper
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2005-03-08  6:05 UTC (permalink / raw)
  To: zsh-users

On Mar 7, 11:41pm, zzapper wrote:
}
} autoload ${fpath[1]}/*(:t) #autoload all functions in $fpath

Well, as you discovered, this actually means:  "Assume the name of
every file in $fpath is also the name of a zsh function, and create
an autoload for every function so named."

} As I also use the same directory for my legacy bash scripts, I was
} unpleasantly surprised to find that these scripts had also been
} autoloaded and were now being treated as zsh scripts.

How (and why) did you expect zsh to tell the two sets of functions
apart if you put them all in the same directories? There's no magic
here; zsh doesn't examine the contents of the files for #! lines or
anything like that -- for one thing, many functions don't have a #!
line because they're not designed to be executed as standalone scripts.  

} Easy to fix, either I make the scripts zsh compatible or move them
} elsewhere.

A third possibility is to zcompile only the zsh functions, then use
"autoload -w" to load them.

} Q2) I was surprised to what extent my bash scripts worked as zsh
} (mostly only required the adding of a pre-declaration of any
} variables), is a reasonable proportion of bash available from within
} zsh?

Both bash and zsh are to a significant degree compatible with the
POSIX shell standard, so yes, they have a lot of overlap, and if you
don't use any of the special features of either shell, then the same
scripts and functions should work in both.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Autoloaded bash shell scripts treated as zsh
  2005-03-08  6:05 ` Bart Schaefer
@ 2005-03-08 10:21   ` zzapper
  2005-03-08 10:26     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: zzapper @ 2005-03-08 10:21 UTC (permalink / raw)
  To: zsh-users

On Tue, 08 Mar 2005 06:05:21 +0000,  wrote:

>On Mar 7, 11:41pm, zzapper wrote:
>}
>} autoload ${fpath[1]}/*(:t) #autoload all functions in $fpath
>
>Well, as you discovered, this actually means:  "Assume the name of
>every file in $fpath is also the name of a zsh function, and create
>an autoload for every function so named."
>
>} As I also use the same directory for my legacy bash scripts, I was
>} unpleasantly surprised to find that these scripts had also been
>} autoloaded and were now being treated as zsh scripts.
>
>How (and why) did you expect zsh to tell the two sets of functions
>apart if you put them all in the same directories? There's no magic.
Bart, just forgot they were there!

BTW what's the best way to reload/unload a shell function you are working on?

I've been calling it directly

./myshell



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Autoloaded bash shell scripts treated as zsh
  2005-03-08 10:21   ` zzapper
@ 2005-03-08 10:26     ` Peter Stephenson
  2005-03-08 10:36       ` zzapper
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2005-03-08 10:26 UTC (permalink / raw)
  To: zsh-users

zzapper wrote:
> BTW what's the best way to reload/unload a shell function you are working on?

I've had this function for ages.

reload() {
  if (( $# == 0 )); then
    print "Reload what?" >&2
    return 1
  fi

  while (( $# )); do
    unfunction $1 && autoload $1
    shift
  done
}

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Autoloaded bash shell scripts treated as zsh
  2005-03-08 10:26     ` Peter Stephenson
@ 2005-03-08 10:36       ` zzapper
  0 siblings, 0 replies; 5+ messages in thread
From: zzapper @ 2005-03-08 10:36 UTC (permalink / raw)
  To: zsh-users

On Tue, 08 Mar 2005 10:26:18 +0000,  wrote:

>reload() {
>  if (( $# == 0 )); then
>    print "Reload what?" >&2
>    return 1
>  fi
>
>  while (( $# )); do
>    unfunction $1 && autoload $1
>    shift
>  done
>}

Thanx Peter, i'll borrow that thanx.

It's easy to forget that you can't just edit a zsh autoloaded function, and then run it!!



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-03-08 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-07 23:41 Autoloaded bash shell scripts treated as zsh zzapper
2005-03-08  6:05 ` Bart Schaefer
2005-03-08 10:21   ` zzapper
2005-03-08 10:26     ` Peter Stephenson
2005-03-08 10:36       ` zzapper

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).