xref: /freebsd/contrib/dialog/samples/rotated-data (revision a96ef4501919d7ac08e94e98dc34b0bdd744802b)
14c8945a0SNathan Whitehorn#!/bin/sh
2*a96ef450SBaptiste Daroussin# $Id: rotated-data,v 1.2 2019/12/10 23:59:24 tom Exp $
34c8945a0SNathan Whitehorn# Rotate the second parameter's data by the given shift count.
44c8945a0SNathan Whitehornif test $# != 0
54c8945a0SNathan Whitehornthen
64c8945a0SNathan Whitehorn	case $1 in
74c8945a0SNathan Whitehorn	[1-9]*)
84c8945a0SNathan Whitehorn		left=$1
9*a96ef450SBaptiste Daroussin		next=`expr "$left" + 1`
104c8945a0SNathan Whitehorn		shift 1
114c8945a0SNathan Whitehorn		;;
124c8945a0SNathan Whitehorn	*)
134c8945a0SNathan Whitehorn		left=1
144c8945a0SNathan Whitehorn		next=2
154c8945a0SNathan Whitehorn		;;
164c8945a0SNathan Whitehorn	esac
174c8945a0SNathan Whitehorn	char=`echo "$@" | cut -b -${left}`
184c8945a0SNathan Whitehorn	data=`echo "$@" | cut -b ${next}-`
194c8945a0SNathan Whitehorn
20*a96ef450SBaptiste Daroussin	printf "%s%s\n" "$data" "$char"
214c8945a0SNathan Whitehornelse
224c8945a0SNathan Whitehorn	echo
234c8945a0SNathan Whitehornfi
24