WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: [Not a] Bug: Command "mounted" in busybox shell CorePlus 5.0rc1 and dCore 5.0rc2  (Read 2167 times)

Offline cpoakes

  • Newbie
  • *
  • Posts: 32
Typing "mounted" at the (busybox ash) shell prompt hangs until Ctrl-C (SIGINT) in CorePlus 5.0rc1 and dCore 5.0rc2.  Command "which" does not find any executable named mounted.  Command "sudo find / -name mounted" returns nothing.  Command "busybox mounted" is an error.  There is no "builtin" or "help" to identify shell builtins, however "strings /bin/sh" (operating on link to busybox) shows only messages containing the word, but no bare word as with other builtin shell commands. 

If you create a script named "mounted" and place it in the First directory of your PATH , the script will not execute.  Executes if you specify a full pathname for the command.  It is as if /bin/busybox ash is treating it as a builtin...

On dd-wrt (busybox ash), openwrt (busybox ash), Buffalo NAS (busybox ash) typing "mounted" gives the expected:

$ mounted
ash: mounted not found

What in the world is (not) happening?
« Last Edit: September 10, 2013, 06:27:55 PM by cpoakes »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Bug: Command "mounted" in busybox shell CorePlus 5.0rc1 and dCore 5.0rc2
« Reply #1 on: September 10, 2013, 05:10:40 PM »
mounted is an ash function in /etc/init.d/tc-functions
mounted /dev/sda1
returns 0 if /dev/sda1 is mounted, and 1 if it is not.

mounted /dev/sda1 && echo "yes" || echo "no"

if mounted $DEV ; then
   echo "$DEV is mounted
else
   echo "$DEV" is not mounted
fi
« Last Edit: September 10, 2013, 05:18:48 PM by gerald_clark »

Offline cpoakes

  • Newbie
  • *
  • Posts: 32
Re: Bug: Command "mounted" in busybox shell CorePlus 5.0rc1 and dCore 5.0rc2
« Reply #2 on: September 10, 2013, 06:26:44 PM »
Thanks - this was driving me crazy.  Had issued "set" to see what functions were defined in the shell, but apparently this is a bashism - no function definitions were reported.  But I should've tried an "unset mounted" anyway.  Anyone know how to get ash to report defined functions? 

Removed the line sourcing tc-functions from my .ashrc - all is well.

Suggestion: /etc/init.d/tc-functions mounted() should quote the "$1" argument.  Without the quotes, a null string causes grep to utilize "/etc/mtab" as the pattern on stdin - certainly not the intended action.  Would also keep the command from appearing to hang while waiting for an end-of-file.