You're viewing a comment by MicheleVenturi and its responses.

September 29, 2015, 23:08

This works in zsh but not in bash cause of the nested parameter expansion.

#!/bin/zsh
S=$(eval echo\ "\{\,-$1-\}")
P=$(eval echo\ "{${S// /}}")
echo {${${P//(--| )/,}//-/}}

Can be used like this: SET='{a,b,c}'; ./power-set.sh $SET
It outputs: {{},{c},{b},{b,c},{a},{a,c},{a,b},{a,b,c}}

P.S. How can i delete a comment?

Reply To This Comment

(why do I need your e-mail?)

(Your twitter handle, if you have one.)

Type the word "antispam_97": (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.