[BACK]Return to cmd-set-environment.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / tmux

Diff for /src/usr.bin/tmux/cmd-set-environment.c between version 1.20 and 1.21

version 1.20, 2016/10/14 22:14:22 version 1.21, 2016/10/16 19:04:05
Line 27 
Line 27 
  * Set an environment variable.   * Set an environment variable.
  */   */
   
 static enum cmd_retval   cmd_set_environment_exec(struct cmd *, struct cmd_q *);  static enum cmd_retval  cmd_set_environment_exec(struct cmd *,
                               struct cmdq_item *);
   
 const struct cmd_entry cmd_set_environment_entry = {  const struct cmd_entry cmd_set_environment_entry = {
         .name = "set-environment",          .name = "set-environment",
Line 43 
Line 44 
 };  };
   
 static enum cmd_retval  static enum cmd_retval
 cmd_set_environment_exec(struct cmd *self, struct cmd_q *cmdq)  cmd_set_environment_exec(struct cmd *self, struct cmdq_item *item)
 {  {
         struct args     *args = self->args;          struct args     *args = self->args;
         struct environ  *env;          struct environ  *env;
Line 51 
Line 52 
   
         name = args->argv[0];          name = args->argv[0];
         if (*name == '\0') {          if (*name == '\0') {
                 cmdq_error(cmdq, "empty variable name");                  cmdq_error(item, "empty variable name");
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
         if (strchr(name, '=') != NULL) {          if (strchr(name, '=') != NULL) {
                 cmdq_error(cmdq, "variable name contains =");                  cmdq_error(item, "variable name contains =");
                 return (CMD_RETURN_ERROR);                  return (CMD_RETURN_ERROR);
         }          }
   
Line 67 
Line 68 
         if (args_has(self->args, 'g'))          if (args_has(self->args, 'g'))
                 env = global_environ;                  env = global_environ;
         else {          else {
                 if (cmdq->state.tflag.s == NULL) {                  if (item->state.tflag.s == NULL) {
                         target = args_get(args, 't');                          target = args_get(args, 't');
                         if (target != NULL)                          if (target != NULL)
                                 cmdq_error(cmdq, "no such session: %s", target);                                  cmdq_error(item, "no such session: %s", target);
                         else                          else
                                 cmdq_error(cmdq, "no current session");                                  cmdq_error(item, "no current session");
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
                 env = cmdq->state.tflag.s->environ;                  env = item->state.tflag.s->environ;
         }          }
   
         if (args_has(self->args, 'u')) {          if (args_has(self->args, 'u')) {
                 if (value != NULL) {                  if (value != NULL) {
                         cmdq_error(cmdq, "can't specify a value with -u");                          cmdq_error(item, "can't specify a value with -u");
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
                 environ_unset(env, name);                  environ_unset(env, name);
         } else if (args_has(self->args, 'r')) {          } else if (args_has(self->args, 'r')) {
                 if (value != NULL) {                  if (value != NULL) {
                         cmdq_error(cmdq, "can't specify a value with -r");                          cmdq_error(item, "can't specify a value with -r");
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
                 environ_clear(env, name);                  environ_clear(env, name);
         } else {          } else {
                 if (value == NULL) {                  if (value == NULL) {
                         cmdq_error(cmdq, "no value specified");                          cmdq_error(item, "no value specified");
                         return (CMD_RETURN_ERROR);                          return (CMD_RETURN_ERROR);
                 }                  }
                 environ_set(env, name, "%s", value);                  environ_set(env, name, "%s", value);

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.21