Changeset View
Changeset View
Standalone View
Standalone View
bin/sh/dotcmd/scoped_command
#!/bin/sh | #!/bin/sh | ||||
# | # | ||||
# $NetBSD: scoped_command,v 1.2 2016/03/27 14:57:50 christos Exp $ | # $NetBSD: scoped_command,v 1.3 2018/12/04 09:47:25 kre Exp $ | ||||
# | # | ||||
# Copyright (c) 2014 The NetBSD Foundation, Inc. | # Copyright (c) 2014 The NetBSD Foundation, Inc. | ||||
# All rights reserved. | # All rights reserved. | ||||
# | # | ||||
# This code is derived from software contributed to The NetBSD Foundation | # This code is derived from software contributed to The NetBSD Foundation | ||||
# by Jarmo Jaakkola. | # by Jarmo Jaakkola. | ||||
# | # | ||||
# Redistribution and use in source and binary forms, with or without | # Redistribution and use in source and binary forms, with or without | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
# until, while. | # until, while. | ||||
# _cmd_ is the command line to execute. Remember proper quoting! | # _cmd_ is the command line to execute. Remember proper quoting! | ||||
# _msg_ is text that will be used inside single quotes. | # _msg_ is text that will be used inside single quotes. | ||||
# _var_suffix_ is a syntactically valid identifier name. | # _var_suffix_ is a syntactically valid identifier name. | ||||
# don't rely on command lists (';') | # don't rely on command lists (';') | ||||
cmd="echo 'before ${3}' | cmd="echo 'before ${3}' | ||||
${2} | ${2} | ||||
echo 'after ${3}, return value:' ${?}" | echo 'after ${3}, return value:' \${?}" | ||||
echo "#!${TEST_SH}" | echo "#!${TEST_SH}" | ||||
[ 'func' = "${1}" ] && cat <<EOF | [ 'func' = "${1}" ] && cat <<EOF | ||||
func() | func() | ||||
{ | { | ||||
echo 'before ${3}' | echo 'before ${3}' | ||||
\${1} | \${1} | ||||
▲ Show 20 Lines • Show All 68 Lines • Show Last 20 Lines |