Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Sorting file names randomly



On Jul 25,  3:15pm, DervishD wrote:
}
} > it would be better to declare "local +h -Z 5 RANDOM"
} > (Just remember to seed RANDOM when making it local.)
} 
}     Just to make sure: you can do whatever thing you want with
} 'typeset' on a predefined shell parameter just like you would do with
} your own parameters, right? Any important limitation?

[From the follow-up message]
}     Anyway my question is still valid: can you do any valid
} modification (not only -Z, but -L, -R, etc., -i, -E, -F...) to them
} or every special parameter has its own constraints?

There are no constraints if you use -h to hide the special meaning.

When using +h, the constraints imposed by the predefined type of each
parameter will apply.  For example, you can't turn RANDOM into a float
or an array, and specifying zero-padding for USERNAME will instead pad
with spaces because you can't change the string to an integer.

} > Fourth, you've eventually got to do this ...
} > }     reply=(${reply/#????? /})
} 
}     Here I assumed that the array was processed one element at a time
} so I didn't consider that the memory usage doubled. Cool :)))

The ${reply/#????? /} part is processed one element at a time, but the
entire right-side of the assignment expression has to be assembled from
the results of the substitution before the actual assignment is done.

}     Bart, thanks a lot for your examples, but LOT'S of thanks for
} your explanations.

Por nada.  Just keep asking interesting questions.



Messages sorted by: Reverse Date, Date, Thread, Author