anchor.diff:       node>peer @ swap node>parent @ node>child !
        EXIT
      THEN
  -       dup node>peer @
  -       BEGIN 2 pick 2dup <> WHILE
  -	     drop
  -        	nip dup node>peer @
  -	   dup 0= IF 2drop drop unloop EXIT THEN
  -      REPEAT
  -         drop
  -    node>peer @ 	swap node>peer !
  +   dup node>peer @
  +   BEGIN
  +      2 pick 2dup <>
  +   WHILE
         drop
  +      nip dup node>peer @
  +      dup 0= IF 2drop drop unloop EXIT THEN
  +   REPEAT
  +   drop
  +   node>peer @  swap node>peer !
  +   drop
   ;
   
   
   : open-dev ( path len -- ihandle|0 )
  -  de-alias current-node @ >r
  -  handle-leading-/ current-node @ 0= IF 2drop r> set-node 0 EXIT THEN
  -  my-self >r 0 to my-self
  -  0 0 >r >r BEGIN dup WHILE \ handle one component:
  -  ( arg len ) r> r> get-node open-node to my-self
  -  find-component ( path len args len node ) dup 0= IF
  -  3drop 2drop my-self close-dev r> to my-self r> set-node 0 EXIT THEN
  -  set-node >r >r REPEAT 2drop
  +   de-alias current-node @ >r
  +   handle-leading-/ current-node @ 0= IF 2drop r> set-node 0 EXIT THEN
  +   my-self >r
  +   0 to my-self
  +   0 0 >r >r
  +   BEGIN
  +      dup
  +   WHILE \ handle one component:
  +     ( arg len ) r> r> get-node open-node to my-self
  +     find-component ( path len args len node ) dup 0= IF
  +        3drop 2drop my-self close-dev
  +        r> to my-self
  +        r> set-node
  +        0 EXIT
  +     THEN
  +     set-node
  +     >r >r
  +  REPEAT
  +  2drop
     \ open final node
     r> r> get-node open-node to my-self
  -  my-self r> to my-self r> set-node ;
  +  my-self r> to my-self r> set-node
  +;
  +
   : select-dev  open-dev dup to my-self ihandle>phandle set-node ;
   : unselect-dev  my-self close-dev  0 to my-self  device-end ;
   
  
positive.code: \ sub-alias does a single iteration of an alias at the begining od dev path
  \ expression. de-alias will repeat this until all indirect alising is resolved
  : sub-alias ( arg-str arg-len -- arg' len' | false )
  	2dup
  	2dup [char] / findchar ?dup IF ELSE 2dup [char] : findchar THEN
  	( a l a l [p] -1|0 ) IF nip dup ELSE 2drop 0 THEN >r
  	( a l l p -- R:p | a l -- R:0 )
  	find-alias ?dup IF ( a l a' p' -- R:p | a' l' -- R:0 )
  		r@ IF 2swap r@ - swap r> + swap $cat strdup ( a" l-p+p' -- )
  		ELSE ( a' l' -- R:0 ) r> drop ( a' l' -- ) THEN
  	ELSE ( a l -- R:p | -- R:0 ) r> IF 2drop THEN false ( 0 -- ) THEN
  ;
  
  : de-alias ( arg-str arg-len -- arg' len' )
  	BEGIN over c@ [char] / <> dup IF drop 2dup sub-alias ?dup THEN
  	WHILE 2swap 2drop REPEAT
  ;
  
  
  
negative.code: ;
  
  : find-alias ( alias-name len -- false | dev-path len )
     s" /aliases" find-node dup IF
        get-property 0= IF 1- dup 0= IF nip THEN ELSE false THEN
     THEN
  ;
  
  : .alias ( alias-name len -- )
      find-alias dup IF type ELSE ." no alias available" THEN ;
  