#!/bin/bash # Tests monitoring for environment additions # # Copyright (C) 2014 Mike Gerwitz # # This file is part of pkgsh. # # pkgsh is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # # Tests monitoring the environment for variable additions ## source src/envmon.sh # initialize to the current state of the environment _pkgsh-envmon-init # add two variables to the environment (note that one contains newlines to # ensure that they do not cause problems) export foo=a bar=newline$'\n'test declare -A found=() # perform env addition diff while read -d $'\0' env; do var="${env%%=*}" val="${env#*=}" found[$var]="$val" done < <( _pkgsh-envmon-diff-adds ) # ensure each was found for name in foo bar; do eval chk="\$$name" assert "${found[$name]}" == "$chk" done # ensure that no others were found assert "${#found[@]}" -eq 2