zsh-users
 help / color / mirror / code / Atom feed
* let unset array element remove compatible with bash
@ 2012-02-22  3:28 Daniel Lin
  2012-02-22  5:41 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lin @ 2012-02-22  3:28 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 983 bytes --]

As we know, bash is very common on Linux world.
So, even I've moved to zsh.
But, I wish my script could be compatible with bash.

Today, I found the array element remove is not compatible with bash.
Can any developer consider to enhance zsh's function like "unset var[2]"?

Here is the sample


  $var[1]="four" ; var[2]="seven" ; var[3]="Four and
Seven"
  $for v in "${var[@]}" ; do echo "$v" ;
done

four


seven

  Four and
Seven
  $for v in "${var[*]}" ; do echo "$v" ;
done
  four seven Four and
Seven
  $echo "${#var[@]} ${#var[1]} ${#var[2]} ${#var[3]}"  # get
lengh
  3 4 5
14
  $unset var[2] ###### BASH only delete one
element
  $var[2]=() ###### ZSH only delete one
element
  $echo "${#var[@]} ${#var[1]} ${#var[2]}
${#var[3]}"
  2 4 0 14

Another note, I wish the FAQ in zsh can explain this incompatible with bash.

$echo "${#var[@]} ${#var[1]} ${#var[2]} ${#var[3]}"  # get lengh  work both
bash/zsh
$echo "$#var $#var[1] $#var[2] $#var[3]"  # get lengh  work only zsh

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

end of thread, other threads:[~2012-02-22 14:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-22  3:28 let unset array element remove compatible with bash Daniel Lin
2012-02-22  5:41 ` Bart Schaefer
2012-02-22 14:18   ` Chet Ramey

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).