- print(''' echo {!r} |\n openconnect --protocol=gp --user={!r} --usergroup={}:{} --passwd-on-stdin {}\n'''.format(
- cv, un, ('portal' if args.portal else 'gateway'), cn, args.server), file=stderr)
-
- print("HOST={!r}\nUSER={!r}\nCOOKIE={!r}".format('https://%s/%s:%s' % (args.server, ('portal' if args.portal else 'gateway'), cn), un, cv))
+ print(''' echo {} |\n openconnect --protocol=gp --user={} --usergroup={}:{} --passwd-on-stdin {}\n'''.format(
+ quote(cv), quote(un), quote(shortpath), quote(cn), quote(args.server)), file=stderr)
+
+ varvals = {
+ 'HOST': quote('https://%s/%s:%s' % (args.server, shortpath, cn)),
+ 'USER': quote(un), 'COOKIE': quote(cv),
+ }
+ print('\n'.join('%s=%s' % pair for pair in varvals.items()))