* Issue with string slices @ 2019-06-17 8:36 ` joão marcos pereira bezerra 2019-06-17 8:51 ` Peter Stephenson 0 siblings, 1 reply; 5+ messages in thread From: joão marcos pereira bezerra @ 2019-06-17 8:36 UTC (permalink / raw) To: zsh-workers [-- Attachment #1: Type: text/plain, Size: 363 bytes --] Zsh is not printing the character "-" Example 1: arg="--help" echo ${arg[1]} echo ${arg[2]} echo ${arg[3]} Expected: - - h Got: (new line empty) (new line empty) h Example 2: arg="--help" echo ${arg:0:1} echo ${arg:0:2} echo ${arg:1:1} echo ${arg:1:2} Expected: - - - h Got: (new line empty) -- (new line empty) -h ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue with string slices 2019-06-17 8:36 ` Issue with string slices joão marcos pereira bezerra @ 2019-06-17 8:51 ` Peter Stephenson 2019-06-17 9:05 ` Roman Perepelitsa 0 siblings, 1 reply; 5+ messages in thread From: Peter Stephenson @ 2019-06-17 8:51 UTC (permalink / raw) To: zsh-workers; +Cc: joão marcos pereira bezerra On Mon, 2019-06-17 at 08:36 +0000, joão marcos pereira bezerra wrote: > Zsh is not printing the character "-" With echo, you mean --- I don't think this has got anything to do with string slices. Correct, this is documented as very long-standing behaviour. Note that for standards compliance a double dash does not termi- nate option processing; instead, it is printed directly. How- ever, a single dash does terminate option processing, so the first dash, possibly following options, is not printed, but everything following it is printed as an argument. The single dash behaviour is different from other shells. For a more por- table way of printing text, see printf, and for a more control- lable way of printing text within zsh, see print. pws ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue with string slices 2019-06-17 8:51 ` Peter Stephenson @ 2019-06-17 9:05 ` Roman Perepelitsa 2019-06-17 16:15 ` joão marcos pereira bezerra 2019-06-18 18:12 ` Stephane Chazelas 0 siblings, 2 replies; 5+ messages in thread From: Roman Perepelitsa @ 2019-06-17 9:05 UTC (permalink / raw) To: Peter Stephenson; +Cc: Zsh hackers list, joão marcos pereira bezerra To print $something as is, use one of these forms: echo -nE - "$something" print -nr -- "$something" printf '%s' "$something" The first two are ZSH specific, the last is portable. ZSH also allows you to omit quotes here unless SH_WORD_SPLIT option is set. Roman. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue with string slices 2019-06-17 9:05 ` Roman Perepelitsa @ 2019-06-17 16:15 ` joão marcos pereira bezerra 2019-06-18 18:12 ` Stephane Chazelas 1 sibling, 0 replies; 5+ messages in thread From: joão marcos pereira bezerra @ 2019-06-17 16:15 UTC (permalink / raw) To: Roman Perepelitsa, Peter Stephenson; +Cc: Zsh hackers list [-- Attachment #1: Type: text/plain, Size: 634 bytes --] Thanks guys, i was unsure if i should report this issue Get Outlook for Android<https://aka.ms/ghei36> ________________________________ From: Roman Perepelitsa <roman.perepelitsa@gmail.com> Sent: Monday, June 17, 2019 6:05:32 AM To: Peter Stephenson Cc: Zsh hackers list; joão marcos pereira bezerra Subject: Re: Issue with string slices To print $something as is, use one of these forms: echo -nE - "$something" print -nr -- "$something" printf '%s' "$something" The first two are ZSH specific, the last is portable. ZSH also allows you to omit quotes here unless SH_WORD_SPLIT option is set. Roman. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Issue with string slices 2019-06-17 9:05 ` Roman Perepelitsa 2019-06-17 16:15 ` joão marcos pereira bezerra @ 2019-06-18 18:12 ` Stephane Chazelas 1 sibling, 0 replies; 5+ messages in thread From: Stephane Chazelas @ 2019-06-18 18:12 UTC (permalink / raw) To: Roman Perepelitsa Cc: Peter Stephenson, Zsh hackers list, joão marcos pereira bezerra 2019-06-17 11:05:32 +0200, Roman Perepelitsa: > To print $something as is, use one of these forms: > > echo -nE - "$something" > print -nr -- "$something" > printf '%s' "$something" > > The first two are ZSH specific, the last is portable. ZSH also allows > you to omit quotes here unless SH_WORD_SPLIT option is set. [...] The second one comes from ksh, it's not zsh-specific and predates POSIX, let alone POSIX's printf, but nowadays is not as portable as printf. If you want to target zsh and ksh only, "print" may be more desirable as there are still some pdksh derivatives where printf is not built-in. "unless SH_WORD_SPLIT *or GLOB_SUBST* is set" -- Stephane ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-06-19 8:07 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <CGME20190617083759epcas1p11383850c11184f54e3a0b822c9ea12e6@epcas1p1.samsung.com> 2019-06-17 8:36 ` Issue with string slices joão marcos pereira bezerra 2019-06-17 8:51 ` Peter Stephenson 2019-06-17 9:05 ` Roman Perepelitsa 2019-06-17 16:15 ` joão marcos pereira bezerra 2019-06-18 18:12 ` Stephane Chazelas
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).