Openbox date-menu.sh menu error

I am using Openbox, and one of the menu items is script that I found from the web site below:
http://openbox.org/wiki/Openbox:Pipemenus:Date_Menu
When I try to execute the code it fails with an error that expects a "(" at line 16. But I can not see what is wrong with it.
Can you help?

Code:
 function calRow() {
   cal | gawk -v row=$1 '{ if (NR==row) { print $0 } }'
 }

Thanks in advance.
 
Often the shell scripts are written for the shells/bash shell. The Default Shell in FreeBSD is tcsh(1). One option would be to review the shell script for bashism's. Another would be to install shells/bash and try running the script in the bash shell.

I took a different route for my x11-wm/openbox configuration. If you are using a panel like x11/tint you can configure the clock entry to call the calendar program of your choice. I use deskutils/osmo. I call my calendar program with a left click on the panel clock with the following x11/tint entry
Code:
# Clock
time1_format = %T
time1_font = sans bold 11
clock_font_color = #FFFFFF 100
clock_tooltip = %A - %B %d, %Y
clock_padding = 0 0
clock_background_id = 0
clock_lclick_command = osmo -c
 
shepper said:
Not true, only the default interactive shell of root is csh(1). For all other purposes such as rc(8) scripts the /bin/sh shell is used.

Is this FreeBSD document incorrect?

It is incorrect and should be corrected. If there is such thing as a default shell it's still /bin/sh, that's what adduser(8) offers as the default for a new user.
 
Thank you very much for answering. I realize I am very new and my questions and issues may try your patience. So I really appreciate it.
 
Marbles said:
I am using Openbox, and one of the menu items is script that I found from the web site below:
http://openbox.org/wiki/Openbox:Pipemenus:Date_Menu
When I try to execute the code it fails with an error that expects a "(" at line 16. But I can not see what is wrong with it.
Can you help?

Code:
 function calRow() {
   cal | gawk -v row=$1 '{ if (NR==row) { print $0 } }'
 }

Thanks in advance.
You've two option:
  • install shells/bash and overwrite first line to #!/usr/local/bin/bash or #!/usr/bin/env bash
  • remove function keyword so function calRow() { will calRow() { (check manual of sh()/"The syntax of a function definition is..." part)

Explanation: in FreeBSD the /bin/sh isn't equal with shells/bash as in most linux distributions (the /bin/sh usually is a symbolic link to /bin/bash).
 
Linux people assume, that /bin/sh = BASH, that is what this script was broken for /bin/sh, here is the version that works with POSIX sh(1).

Code:
#!/bin/sh

calRow() {
  cal | awk -v row=$1 '{ if (NR==row) { print $0 } }'
}

cat << EOFMENU
<openbox_pipe_menu>
  <separator label="$( date +%A\ \ \ \ \ \ \ \ \ \ \ \ %I\:%M\ %p )" />
  <item label="$( date +%B\ %d,\ %Y)" />
  <separator />
  <item label="$( calRow 2 )" />
  <item label="$( calRow 3 )" />
  <item label="$( calRow 4 )" />
  <item label="$( calRow 5 )" />
  <item label="$( calRow 6 )" />
  <item label="$( calRow 7 )" />
  <item label="$( calRow 8 )" />
</openbox_pipe_menu>
EOFMENU
 
I really cannot thank you all enough! :) I am a Linux user learning FreeBSD, so you assessments are spot on. Thanks again.
 
Back
Top