1# This file is part of xenv                         -*- autotest -*-
2# Copyright (C) 2021 Sergey Poznyakoff
3#
4# Xenv is free software; you can redistribute it and/or modify it
5# under the terms of the GNU General Public License as published by the
6# Free Software Foundation; either version 3 of the License, or (at your
7# option) any later version.
8#
9# Xenv is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with xenv. If not, see <http://www.gnu.org/licenses/>. */
16
17AT_SETUP([double-sigil usage])
18AT_DATA([input],
19[Neither $$set nor $$ifdef, nor other preprocessor statements
20(such as $$else) are expanded when used within a string.
21$$ifset X
22They must be the first non-whitespace sequence at the beginning of
23line for them to take effect.
24$$endif
25That's how it is.
26])
27
28AT_CHECK([
29unset X
30xenv < input
31],
32[0],
33[Neither $$set nor $$ifdef, nor other preprocessor statements
34(such as $$else) are expanded when used within a string.
35That's how it is.
36])
37AT_CHECK([
38X=1 xenv < input
39],
40[0],
41[Neither $$set nor $$ifdef, nor other preprocessor statements
42(such as $$else) are expanded when used within a string.
43They must be the first non-whitespace sequence at the beginning of
44line for them to take effect.
45That's how it is.
46])
47
48AT_CHECK([cat input | tr '$' '@' > input.1])
49
50AT_CHECK([
51unset X
52xenv -S @ < input.1
53],
54[0],
55[Neither @@set nor @@ifdef, nor other preprocessor statements
56(such as @@else) are expanded when used within a string.
57That's how it is.
58])
59AT_CHECK([
60X=1 xenv -S @ < input.1
61],
62[0],
63[Neither @@set nor @@ifdef, nor other preprocessor statements
64(such as @@else) are expanded when used within a string.
65They must be the first non-whitespace sequence at the beginning of
66line for them to take effect.
67That's how it is.
68])
69
70AT_CLEANUP