Project

General

Profile

Bug #22

Wrong ${cur_pwd} value

Added by Anonymous about 1 month ago. Updated 26 days ago.

Status:
Resolved
Priority:
Normal
Assignee:
-
Target version:
-
Start date:
09/18/2018
Due date:
% Done:

0%

Estimated time:

Description

I create test xml file

<CLISH_MODULE>

  <COMMAND help="Print" name="print">
    <ACTION>
      echo cmd: ${__cmd}
      echo orig_cmd: ${__orig_cmd}
      echo full_cmd: ${__full_cmd}
      echo params: ${__params}
      echo line: ${__line}
      echo full_line: ${__full_line}
      echo prefix: ${__prefix}
      echo cur_depth: ${__cur_depth}
      echo cur_pwd: ${__cur_pwd}
    </ACTION>
  </COMMAND>

<VIEW name="root-view" restore="depth" depth="0">
  <COMMAND help="" name="deep1" view="my1-view"/>
  <NAMESPACE ref="my1-view" help="true" completion="true" prefix="deep1"/>
</VIEW>

<VIEW name="my1-view" depth="1" prompt="my1-view# ">
  <COMMAND help="" view="my2-view" name="deep2"/>
  <NAMESPACE ref="my2-view" help="true" completion="true" prefix="deep2"/>
</VIEW>

<VIEW name="my2-view" depth="2" prompt="my2-view# ">
  <COMMAND help="" name="deep3" view="my3-view"/>
  <NAMESPACE ref="my3-view" help="true" completion="true" prefix="deep3"/>
</VIEW>

<VIEW name="my3-view" depth="3" prompt="my3-view# ">
</VIEW>

</CLISH_MODULE>

Default view "root-view". If from "root-view" execute command

root-view# deep1 deep2 deep3
my3-view#

my3-view# print
cmd: print
orig_cmd: print
full_cmd: print
params:
line: print
full_line: print
prefix:
cur_depth: 3
cur_pwd:

my3-view# exit
clish: clish/shell/shell_tinyrl.c: 34: clish_shell_renew_prompt: Assertion `view' failed.
Aborted

then ${cur_pwd} will contain empty path instead "deep1 deep2 deep3" and if I try execute exit klish crash. But if before that we do next command
root-view# deep1
my1-view# deep2
my2-view# deep3
my3-view# exit
my2-view# exit
my1-view# exit
root-view# deep1 deep2 deep3
my3-view#

my3-view# print
cmd: print
orig_cmd: print
full_cmd: print
params:
line: print
full_line: print
prefix:
cur_depth: 3
cur_pwd: deep1 deep2 deep3

then ${cur_pwd} will contain valid value

Check on version 2.1.3 and 2.1.4

History

#1 Updated by Serj Kalichev about 1 month ago

  • Status changed from New to In Progress

I need some time to think about it.
The problem is the VIEWs have constant depth values. In your example the klish really has no entries with depths of 2 and 1. "Exit" is broken because it changes the view to the previous view in path stack. But we get into depth=3 immediately after depth=0.

I plan some klish refactoring to get rid of constant VIEW depth. May be it's the only way to implement path stack in a right way.

#2 Updated by Serj Kalichev 26 days ago

  • Status changed from In Progress to Resolved

Fixed in branch 2.1
Internal function "clish_nested_up" now searches for the first not-null entry in pwd stack. So execution of "exit" in deep3 will change view to the "root_view".
The cur_pwd var was fixed. But note it shows the command name without prefix. So the output will be something like this:

$ deep1
$ deep2
$ deep3
$ print
cur_pwd: deep1 deep2 deep3

but

$ deep1 deep2 deep3
$ print
cur_pwd: deep3

Also available in: Atom PDF