@techno HeHe, I saw this: 'If you think this is appalling, check out BashTrix' in the sort thread. Hopefully the sort offered there is better than my proof-of-concept... It might compare favorably to the slim 'sort' in the thread if cut down to a similar size. All those things in BashTrix are necessarily long beacuse of handling some of the normal command-line options. And they are still longer because I coded them so they *might* be easier to read.
As for the thread about readlink, the suggested script is using readlink. I was asking about implementing readlink itself in shell.
bashbox: multicall bash script
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
The dialog/Xdialog/whiptail/kdialog interface is pretty well standardized (though, could use a few patches to make them more compatible). I could write a matching espeak/sphinx voice-dialog wrapper that can be used as a fairly straightforward template for other backends like yad or gtkdialog.
Edit: to make readlink a "builtin", just edit http://git.busybox.net/busybox/tree/inc ... lets.src.h accordingly
@Amigo - I think Bashtrix is great btw... Just figured that anyone who thought my little sort function was abysmal would be overwhelmed by Bashtrix.
Edit: to make readlink a "builtin", just edit http://git.busybox.net/busybox/tree/inc ... lets.src.h accordingly
@Amigo - I think Bashtrix is great btw... Just figured that anyone who thought my little sort function was abysmal would be overwhelmed by Bashtrix.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
Code: Select all
sortline(){
for x in $@;do
[ ! "$FIRST" ] && FIRST=t && set --
i=0
while [ $i -le $# ];do
[ $x -lt $((${@:$((i+1)):1})) ] && break || i=$((i+1))
done
set -- ${@:1:$i} $x ${@:$((i+1)):$(($#-$i))}
done
echo $@
}
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].
This should fix the spaces-in-names problem for dir_tree:
And this:
"'for' splits the input by line"
is not correct. 'for' splits according to the IFS, which by default is 'space tab end-of-line'. I know the comments are old, but felt it would be good to correct it -for posterity...
techno, Can you explain what FIRST is?
Code: Select all
#!/bin/sh
DIR=$1
[ $2 ] && SPACING=$2 || SPACING="|"
for x in * ; do
[ -d "$DIR/$x" ] && echo "$SPACING\`-{"$x && $0 $DIR/$x "$SPACING "
done
"'for' splits the input by line"
is not correct. 'for' splits according to the IFS, which by default is 'space tab end-of-line'. I know the comments are old, but felt it would be good to correct it -for posterity...
techno, Can you explain what FIRST is?
- technosaurus
- Posts: 4853
- Joined: Mon 19 May 2008, 01:24
- Location: Blue Springs, MO
- Contact:
FIRST is poorly named, it should be something like ARGS_RESET
resets $@ to "" on the first iteration (note that this is after the original $@ has been passed to the for loop), on subsequent runs $@ is modified by inserting the current iteration's value into $@ at the sorted location.
Code: Select all
[ ! "$FIRST" ] && FIRST=t && set --
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].