A teenager who killed a pensioner 30 minutes after he was freed by police following a knife attack on a shopkeeper was ordered to be detained for 40 months today.

A judge ordered that the 15-year-old, who cannot be identified because of his age, should serve a further three years under supervision in the community when he will be on licence and can be returned to custody if he breaches its conditions.

Lord Harrower told him at the High Court in Edinburgh: "You were 15 at the time and are still 15. It is shocking that someone so young should have inflicted such unprovoked violence on two elderly gentlemen."

The judge said he was satisfied that a custodial sentence was inevitable in the case of the teenager, who was assessed as posing a risk of further violent crime, but added that it would be substantially less than that faced by a mature offender.

He said there was a "high level" of minimisation of culpability by the killer when he spoke to a social worker preparing a background report on him.

Lord Harrower said he would have imposed a five year term of detention on the teenager but for his earlier guilty pleas.

The teenager admitted that on April 12 this year he assaulted Nadeen Mohammed, 65, at Allison Street, Glasgow, and struck him with a knife to his injury.

He also admitted that on the same day at Victoria Road, in Glasgow, he attacked and killed Patrick Colquhoun, 70.

He punched Mr Colquhoun on the head who fell and struck his head on the ground and died during the culpable homicide.

The judge said that he took into account the offender's age and lack of criminal record and told him: "I have no doubt you bitterly regret your actions that day."

The court heard that there were concerns raised about the boy's behaviour before the attacks and he had come to the attention of social workers and police.

On the day of the assaults, the boy and a friend went to an off-sales shop in Govanhill and demanded the shopkeeper and his son come outside, but were told to leave before Mr Mohammed followed them outside.

Prosecutor Angela Gray KC said: "The boy removed a knife from the waistband of his trousers and made a slashing motion towards Mr Mohammmed striking him on the arm."

The attack victim needed a wound stitched and the teenager went home and spoke to his father. The father then drove back to the shop and told police there that his son "had been involved in an incident".

The boy was arrested and later released that night on an undertaking to appear at Glasgow Sheriff Court on April 30.

He was picked up by his mother but jumped out of her car after becoming angry. Mr Colquhoun had left his local bar to visit a takeaway and the teenager punched him on the head after believing he was urinating on a car rented by his father.

The victim fell backwards and struck his head as he landed. The teenager walked off as members of the public tried to help the stricken victim who suffered a skull fracture, brain bleed and bruising.

The teenage attacker was traced via CCTV and found hiding in a doorway and was arrested.

Defence counsel John Scullion KC submitted that given he was "still very much a child" rehabilitation would be a primary consideration for the court.

Mr Scullion said guidelines for sentencing young persons applied in the first offender's case.

"I think it is fair to say he bitterly regrets his actions and tragic consequences for Mr Colquhoun and his family," he told the court.

Mr Scullion said: "There is evidence suggesting he was going off the rails, culminating in his commission of two serious offences."

The defence counsel said the author of the background report prepared on the offender noted that there was "sustained use of cannabis" by him in the period prior to the crimes.