summaryrefslogtreecommitdiff
path: root/uriprintf
blob: 580ea7ce5caeaf65c1930032c0c0d100af437c96 (plain) (blame)
1
2
3
4
5
6
7
8
9
#!/bin/sh
cutargs="$(printf "%s\n" "$1" | sed 's/%[^sukdPpqfU]//g' | tr '%' '\n' | tail -n+2 | sed 's/^\(.\).*/-\1/g' | tr '\n' ' ')"
count="$(echo $cutargs | tr '-' '\n' | grep -c .)"
if [ "$count" = 0 ];then
  printf "%s\n" "$1"
else
  printfargs="$(printf "%s\n" "$1" | sed 's/%[sukdPpqfU]/%s/g')"
  uricut "$cutargs" | tr '\n' '\0' | xargs -n $count -0 printf "$printfargs"
fi