All pastes #349090 Raw Edit

Someone

public text v1 · immutable
·published 2007-02-10 15:45 UTC
rendered paste body
#!/bin/bash

BASE=~/.maildir
EXCEPTIONS="Spam Search system"

shopt -s extglob dotglob
EXCEPTIONS=${EXCEPTIONS// /|}

for mailbox in $BASE/!(+([^.])|.+($EXCEPTIONS)); do
echo $mailbox
        INDEX+="$mailbox "
done

nmzmail -i $INDEX

## The problem is that some mailboxes contain spaces, they work if
## I run from the command line:
## nmzmail -i "mailbox 1" "mailbox 2"
## But not if I run:
## nmzmail -i mailbox 1 mailbox 2
## nmzmail -i "mailbox 1 mailbox 2"
## nmzmail -i mailbox\ 1 mailbox\ 2

## Therefore these ideas I had were useless:
## * nmzmail -i "$INDEX"
## * INDEX+="\"$mailbox\" "

# -- suggestion for using an array to store any arguments (example below shifts
#    positional parameters, storing them into an array)
#
for (( i=0 ; "$#" > 0; i++ )) ; do

  s["$i"]="$1" && shift

done

printf "%s\n" "${s[@]}"