示例#1
0
文件: shells.py 项目: maxnbk/rez
    def join(cls, command):
        """
        Note: Default to unix sh/bash- friendly behaviour.

        Args:
            command:
                A sequence of program arguments to be joined into a single
                string that can be executed in the current shell.
        Returns:
            A string object representing the command.
        """
        replacements = [
            # escape ` as \`
            ('`', "\\`"),

            # use double quotes, and put double quotes into single quotes -
            # the string $"b is then quoted as "$"'"'"b". This mimics py3.8+
            # shlex.join function, except with double instead of single quotes.
            #
            # We do this because a command like rez-env -- echo 'hey $FOO' needs
            # to be interpreted as echo "hey $FOO" in the runtime - ie we would
            # expect $FOO to get expanded.
            #
            ('"', '"\'"\'"')
        ]

        return shlex_join(command, replacements=replacements)
示例#2
0
 def join(cls, command):
     """
     Args:
         command:
             A sequence of program arguments to be joined into a single
             string that can be executed in the current shell.
     Returns:
         A string object representing the command.
     """
     return shlex_join(command)
示例#3
0
文件: csh.py 项目: sdot-b/rez
    def join(cls, command):
        replacements = [
            # escape ! as \!
            ('!', "\\!"),

            # see Shell.join()
            ('"', '"\'"\'"'),

            # similar to above, but for backticks
            ('`', '"\'`\'"'),

            # escape $ if not part of a valid var ref like $FOO, ${FOO}
            (re.compile(r"\$([^a-zA-Z{])"), '"\'$\'"\\1'),
            (re.compile(r"\$$"), '"\'$\'"')  # edge case, $ at end
        ]

        return shlex_join(command, replacements=replacements)
示例#4
0
    def command(self, value):
        if self.passive:
            return

        if hasattr(value, '__iter__'):
            it = iter(value)
            cmd = EscapedString.disallow(it.next())
            value = [cmd] + [self.escape_string(x) for x in it]
        else:
            value = EscapedString.disallow(value)
            value = self.escape_string(value)

        try:
            p = self.subprocess(value)
            p.communicate()
        except Exception as e:
            cmd = shlex_join(value)
            raise RexError('Error executing command: %s\n%s' % (cmd, str(e)))
示例#5
0
    def command(self, value):
        if self.passive:
            return

        if is_non_string_iterable(value):
            it = iter(value)
            cmd = EscapedString.disallow(next(it))
            value = [cmd] + [self.escape_string(x) for x in it]
        else:
            value = EscapedString.disallow(value)
            value = self.escape_string(value)

        try:
            p = self.subprocess(value)
            p.communicate()
        except Exception as e:
            cmd = shlex_join(value)
            raise RexError('Error executing command: %s\n%s' % (cmd, str(e)))
示例#6
0
    def join(cls, command):
        if isinstance(command, six.string_types):
            return command

        replacements = [
            # escape ` as ``
            ('`', "``"),

            # escape " as `"
            ('"', '`"')
        ]

        joined = shlex_join(command, replacements=replacements)

        # add call operator in case executable gets quotes applied
        # https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7.1#call-operator-
        #
        return "& " + joined
示例#7
0
文件: shells.py 项目: rvsiy/rez
 def join(self, command):
     return shlex_join(command)
示例#8
0
 def join(self, command):
     return shlex_join(command)
示例#9
0
 def join(cls, command):
     return shlex_join(command)
示例#10
0
文件: cmd.py 项目: instinct-vfx/rez
 def join(self, command):
     return shlex_join(command).replace("'", '"')
示例#11
0
 def join(self, command):
     return shlex_join(command).replace("'", '"')