DEV Community

Discussion on: What are you learning about this weekend?

Collapse
 
serpent7776 profile image
Serpent7776

Learning how bash Shell Parameter Expansion works with this one liner

.() { , ${1:-1}; }; ,() { local N=$(($1-1)) C=${1/#0*/cd} D=${1/#[1-9*]/../}; ${C/#[1-9]*/,} ${N/-1/} ${2}${D/#0*/} ;}
Enter fullscreen mode Exit fullscreen mode

github.com/serpent7776/bits/tree/m...

Collapse
 
maxfindel profile image
Max F. Findel

This snippet is mind-bogginlgy complex for such a trivial function 🤯

Collapse
 
serpent7776 profile image
Serpent7776

Ah, yes. It'd be just too boring to do it the normal way. But yes, a simple call to printf does the same thing.